summaryrefslogblamecommitdiffstatshomepage
path: root/src/mame/layout/sltblgtk.lay
blob: a9841dc99436e064dd207504ab9f5b1a54a4a319 (plain) (tree)


























































































































































































                                                                         
<?xml version="1.0"?>
<mamelayout version="2">
	<element name="slot1" defstate="0">
		<rect>
			<color red="1.0" green="1.0" blue="1.0" />
		</rect>
		<text string="SLOT 1" state="1">
			<color red="0.0" green="0.0" blue="0.0" />
			<bounds x="0" y="0.1" width="1" height="0.8" />
		</text>
	</element>
	<element name="slot2" defstate="0">
		<rect>
			<color red="1.0" green="1.0" blue="1.0" />
		</rect>
		<text string="SLOT 2" state="1">
			<color red="0.0" green="0.0" blue="0.0" />
			<bounds x="0" y="0.1" width="1" height="0.8" />
		</text>
	</element>
	<element name="slot3" defstate="0">
		<rect>
			<color red="1.0" green="1.0" blue="1.0" />
		</rect>
		<text string="SLOT 3" state="1">
			<color red="0.0" green="0.0" blue="0.0" />
			<bounds x="0" y="0.1" width="1" height="0.8" />
		</text>
	</element>
	<element name="slot4" defstate="0">
		<rect>
			<color red="1.0" green="1.0" blue="1.0" />
		</rect>
		<text string="SLOT 4" state="1">
			<color red="0.0" green="0.0" blue="0.0" />
			<bounds x="0" y="0.1" width="1" height="0.8" />
		</text>
	</element>
	<element name="enter" defstate="0">
		<rect>
			<color red="1.0" green="1.0" blue="1.0" />
		</rect>
		<text string="ENTER" state="1">
			<color red="0.0" green="0.0" blue="0.0" />
			<bounds x="0" y="0.1" width="1" height="0.8" />
		</text>
	</element>
	<element name="p1start" defstate="0">
		<rect>
			<color red="1.0" green="1.0" blue="1.0" />
		</rect>
		<text string="START" state="1">
			<color red="0.0" green="0.0" blue="0.0" />
			<bounds x="0" y="0.1" width="1" height="0.8" />
		</text>
	</element>
	<element name="p2start" defstate="0">
		<rect>
			<color red="1.0" green="1.0" blue="1.0" />
		</rect>
		<text string="2PLAY" state="1">
			<color red="0.0" green="0.0" blue="0.0" />
			<bounds x="0" y="0.1" width="1" height="0.8" />
		</text>
	</element>
	<element name="door0" defstate="1">
		<rect state="0">
			<color red="1.0" green="1.0" blue="1.0" />
		</rect>
		<text string="DOOR OPEN" state="0">
			<color red="0.0" green="0.0" blue="0.0" />
			<bounds x="0" y="0.1" width="1" height="0.8" />
		</text>
	</element>
	<element name="vfd0">
	<led14segsc>
			<color red="0" green="0.6" blue="1.0" />
	</led14segsc>
	</element>

	<view name="Adder and Lamps">
		<bezel name="lamp1" element="slot1">
			<bounds x="145" y="280" width="26" height="14" />
		</bezel>
		<bezel name="lamp3" element="slot2">
			<bounds x="175" y="280" width="26" height="14" />
		</bezel>
		<bezel name="lamp5" element="slot3">
			<bounds x="205" y="280" width="26" height="14" />
		</bezel>
		<bezel name="lamp6" element="slot4">
			<bounds x="235" y="280" width="26" height="14" />
		</bezel>
		<bezel name="lamp7" element="enter">
			<bounds x="265" y="280" width="26" height="14" />
		</bezel>
		<bezel name="lamp18" element="p1start">
			<bounds x="295" y="280" width="26" height="14" />
		</bezel>
		<bezel name="lamp17" element="p2start">
			<bounds x="325" y="280" width="26" height="14" />
		</bezel>
		<bezel name="door" element="door0">
			<bounds x="370" y="280" width="26" height="14" />
		</bezel>
		<screen index="0">
			<bounds x="0" y="0" width="400" height="280" />
		</screen>
	</view>
	<view name="Adder,VFD and Lamps">
		<bezel name="lamp1" element="slot1">
			<bounds x="145" y="280" width="26" height="14" />
		</bezel>
		<bezel name="lamp3" element="slot2">
			<bounds x="175" y="280" width="26" height="14" />
		</bezel>
		<bezel name="lamp5" element="slot3">
			<bounds x="205" y="280" width="26" height="14" />
		</bezel>
		<bezel name="lamp6" element="slot4">
			<bounds x="235" y="280" width="26" height="14" />
		</bezel>
		<bezel name="lamp7" element="enter">
			<bounds x="265" y="280" width="26" height="14" />
		</bezel>
		<bezel name="lamp18" element="p1start">
			<bounds x="295" y="280" width="26" height="14" />
		</bezel>
		<bezel name="lamp17" element="p2start">
			<bounds x="325" y="280" width="26" height="14" />
		</bezel>
		<bezel name="door" element="door0">
			<bounds x="370" y="280" width="26" height="14" />
		</bezel>
		<bezel name="vfd0" element="vfd0" state="0">
			<bounds x="0" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd1" element="vfd0" state="0">
			<bounds x="9" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd2" element="vfd0" state="0">
			<bounds x="18" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd3" element="vfd0" state="0">
			<bounds x="27" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd4" element="vfd0" state="0">
			<bounds x="36" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd5" element="vfd0" state="0">
			<bounds x="45" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd6" element="vfd0" state="0">
			<bounds x="54" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd7" element="vfd0" state="0">
			<bounds x="63" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd8" element="vfd0" state="0">
			<bounds x="72" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd9" element="vfd0" state="0">
			<bounds x="81" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd10" element="vfd0" state="0">
			<bounds x="90" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd11" element="vfd0" state="0">
			<bounds x="99" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd12" element="vfd0" state="0">
			<bounds x="108" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd13" element="vfd0" state="0">
			<bounds x="117" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd14" element="vfd0" state="0">
			<bounds x="126" y="280" width="9" height="14"/>
		</bezel>
		<bezel name="vfd15" element="vfd0" state="0">
			<bounds x="135" y="280" width="9" height="14"/>
		</bezel>
		<screen index="0">
			<bounds x="0" y="0" width="400" height="280" />
		</screen>
	</view>
</mamelayout>
>693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830
// license:BSD-3-Clause
// copyright-holders:Aaron Giles,Paul Leaman
/***************************************************************************

    Cinemat/Leland driver

    Leland sound hardware
    driver by Aaron Giles and Paul Leaman

    -------------------------------------------------------------------

    1st generation sound hardware was controlled by the master Z80.
    It drove either an AY-8910/AY-8912 for music. It also had two DACs
    that were driven by the video refresh. At the end of each scanline
    there are 8-bit DAC samples that can be enabled via the output
    ports on the AY-8910. The DACs run at a fixed frequency of 15.3kHz,
    since they are clocked once each scanline.

    -------------------------------------------------------------------

    2nd generation sound hardware was used in Redline Racer. It
    consisted of an 80186 microcontroller driving 8 8-bit DACs. The
    frequency of the DACs were controlled by one of 3 Intel 8254
    programmable interval timers (PITs):

        DAC number  Clock source
        ----------  -----------------
            0       8254 PIT 1 output 0
            1       8254 PIT 1 output 1
            2       8254 PIT 1 output 2
            3       8254 PIT 2 output 0
            4       8254 PIT 2 output 1
            5-7     8254 PIT 3 output 0

    The clock outputs for each DAC can be read, and are polled to
    determine when data should be updated on the chips. The 80186's
    two DMA channels are generally used to drive the first two DACs,
    with the remaining 6 DACs being fed manually via polling.

    -------------------------------------------------------------------

    3rd generation sound hardware appeared in the football games
    (Quarterback, AAFB) and the later games up through Pigout. This
    variant is closely based on the Redline Racer sound system, but
    they took out two of the DACs and replaced them with a higher
    resolution (10-bit) DAC. The driving clocks have been rearranged
    a bit, and the number of PITs reduced from 3 to 2:

        DAC number  Clock source
        ----------  -----------------
            0       8254 PIT 1 output 0
            1       8254 PIT 1 output 1
            2       8254 PIT 1 output 2
            3       8254 PIT 2 output 0
            4       8254 PIT 2 output 1
            5       8254 PIT 2 output 2
            10-bit  80186 timer 0

    Like the 2nd generation board, the first two DACs are driven via
    the DMA channels, and the remaining 5 DACs are polled.

    -------------------------------------------------------------------

    4th generation sound hardware showed up in Ataxx, Indy Heat, and
    World Soccer Finals. For this variant, they removed one more PIT
    and 3 of the 8-bit DACs, and added a YM2151 music chip and an
    externally-fed 8-bit DAC.

        DAC number  Clock source
        ----------  -----------------
            0       8254 PIT 1 output 0
            1       8254 PIT 1 output 1
            2       8254 PIT 1 output 2
            10-bit  80186 timer 0
            ext     80186 timer 1

    The externally driven DACs have registers for a start/stop address
    and triggers to control the clocking.

***************************************************************************/

#include "emu.h"
#include "audio/leland.h"

#include "cpu/z80/z80.h"
#include "sound/volt_reg.h"
#include "speaker.h"

#define LOG_COMM 0
#define LOG_EXTERN 0

/*************************************
 *
 *  2nd-4th generation sound
 *
 *************************************/

WRITE_LINE_MEMBER(leland_80186_sound_device::pit0_2_w)
{
	set_clock_line(2, state);
}

WRITE_LINE_MEMBER(leland_80186_sound_device::pit1_0_w)
{
	set_clock_line(3, state);
}

WRITE_LINE_MEMBER(leland_80186_sound_device::pit1_1_w)
{
	set_clock_line(4, state);
}

WRITE_LINE_MEMBER(leland_80186_sound_device::pit1_2_w)
{
	set_clock_line(5, state);
}

WRITE_LINE_MEMBER(leland_80186_sound_device::i80186_tmr0_w)
{
	set_clock_line(6, state);
}

WRITE_LINE_MEMBER(leland_80186_sound_device::i80186_tmr1_w)
{
	if (state)
	{
		if (m_ext_active && (m_ext_start < m_ext_stop))
		{
			m_dac[3]->write(m_ext_base[m_ext_start]);
			m_ext_start++;
		}
	}
	set_clock_line(7, state);
}

void leland_80186_sound_device::device_add_mconfig(machine_config &config)
{
	I80186(config, m_audiocpu, 16_MHz_XTAL);
	m_audiocpu->set_addrmap(AS_PROGRAM, &leland_80186_sound_device::leland_80186_map_program);
	m_audiocpu->set_addrmap(AS_IO, &leland_80186_sound_device::leland_80186_map_io);
	m_audiocpu->chip_select_callback().set(FUNC(leland_80186_sound_device::peripheral_ctrl));
	m_audiocpu->tmrout0_handler().set(FUNC(leland_80186_sound_device::i80186_tmr0_w));

	SPEAKER(config, "speaker").front_center();
	for (int i = 0; i < 6; i++)
	{
		AD7524(config, m_dac[i], 0).add_route(ALL_OUTPUTS, "speaker", 0.2); // 74hc374.u31..6 + ad7524.u46..51
		DAC_8BIT_BINARY_WEIGHTED(config, m_dacvol[i], 0); // 74hc374.u17..22 + rX2-rX9 (24k,12k,6.2k,3k,1.5k,750,360,160) where X is 0..5
	}
	AD7533(config, "dac9", 0).add_route(ALL_OUTPUTS, "speaker", 1.0); // ad7533.u64

	m_dacvol[0]->add_route(0, "dac1", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[0]->add_route(0, "dac1", -1.0, DAC_VREF_NEG_INPUT);
	m_dacvol[1]->add_route(0, "dac2", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[1]->add_route(0, "dac2", -1.0, DAC_VREF_NEG_INPUT);
	m_dacvol[2]->add_route(0, "dac3", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[2]->add_route(0, "dac3", -1.0, DAC_VREF_NEG_INPUT);
	m_dacvol[3]->add_route(0, "dac4", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[3]->add_route(0, "dac4", -1.0, DAC_VREF_NEG_INPUT);
	m_dacvol[4]->add_route(0, "dac5", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[4]->add_route(0, "dac5", -1.0, DAC_VREF_NEG_INPUT);
	m_dacvol[5]->add_route(0, "dac6", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[5]->add_route(0, "dac6", -1.0, DAC_VREF_NEG_INPUT);

	voltage_regulator_device &vref(VOLTAGE_REGULATOR(config, "vref", 0));
	vref.set_output(5.0);
	vref.add_route(0, "dac1vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac2vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac3vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac4vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac5vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac6vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac9", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac9", -1.0, DAC_VREF_NEG_INPUT);

	PIT8254(config, m_pit[0], 0);
	m_pit[0]->set_clk<0>(4000000);
	m_pit[0]->out_handler<0>().set(m_audiocpu, FUNC(i80186_cpu_device::drq0_w));
	m_pit[0]->set_clk<1>(4000000);
	m_pit[0]->out_handler<1>().set(m_audiocpu, FUNC(i80186_cpu_device::drq1_w));
	m_pit[0]->set_clk<2>(4000000);
	m_pit[0]->out_handler<2>().set(FUNC(leland_80186_sound_device::pit0_2_w));

	PIT8254(config, m_pit[1], 0);
	m_pit[1]->set_clk<0>(4000000);
	m_pit[1]->out_handler<0>().set(FUNC(leland_80186_sound_device::pit1_0_w));
	m_pit[1]->set_clk<1>(4000000);
	m_pit[1]->out_handler<1>().set(FUNC(leland_80186_sound_device::pit1_1_w));
	m_pit[1]->set_clk<2>(4000000);
	m_pit[1]->out_handler<2>().set(FUNC(leland_80186_sound_device::pit1_2_w));

	GENERIC_LATCH_16(config, m_soundlatch);
}

void redline_80186_sound_device::device_add_mconfig(machine_config &config)
{
	I80186(config, m_audiocpu, 16_MHz_XTAL);
	m_audiocpu->set_addrmap(AS_PROGRAM, &redline_80186_sound_device::leland_80186_map_program);
	m_audiocpu->set_addrmap(AS_IO, &redline_80186_sound_device::redline_80186_map_io);
	m_audiocpu->chip_select_callback().set(FUNC(leland_80186_sound_device::peripheral_ctrl));

	SPEAKER(config, "speaker").front_center();
	for (int i = 0; i < 8; i++)
	{
		AD7524(config, m_dac[i], 0).add_route(ALL_OUTPUTS, "speaker", 0.2); // unknown DAC
		DAC_8BIT_BINARY_WEIGHTED(config, m_dacvol[i], 0);
	}

	m_dacvol[0]->add_route(0, "dac1", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[0]->add_route(0, "dac1", -1.0, DAC_VREF_NEG_INPUT); // unknown DAC
	m_dacvol[1]->add_route(0, "dac2", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[1]->add_route(0, "dac2", -1.0, DAC_VREF_NEG_INPUT); // unknown DAC
	m_dacvol[2]->add_route(0, "dac3", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[2]->add_route(0, "dac3", -1.0, DAC_VREF_NEG_INPUT); // unknown DAC
	m_dacvol[3]->add_route(0, "dac4", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[3]->add_route(0, "dac4", -1.0, DAC_VREF_NEG_INPUT); // unknown DAC
	m_dacvol[4]->add_route(0, "dac5", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[4]->add_route(0, "dac5", -1.0, DAC_VREF_NEG_INPUT); // unknown DAC
	m_dacvol[5]->add_route(0, "dac6", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[5]->add_route(0, "dac6", -1.0, DAC_VREF_NEG_INPUT); // unknown DAC
	m_dacvol[6]->add_route(0, "dac7", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[6]->add_route(0, "dac7", -1.0, DAC_VREF_NEG_INPUT); // unknown DAC
	m_dacvol[7]->add_route(0, "dac8", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[7]->add_route(0, "dac8", -1.0, DAC_VREF_NEG_INPUT); // unknown DAC

	voltage_regulator_device &vref(VOLTAGE_REGULATOR(config, "vref", 0));
	vref.set_output(5.0);
	vref.add_route(0, "dac1vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac2vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac3vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac4vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac5vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac6vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac7vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac8vol", 1.0, DAC_VREF_POS_INPUT);

	PIT8254(config, m_pit[0], 0);
	m_pit[0]->set_clk<0>(7000000);
	m_pit[0]->out_handler<0>().set(m_audiocpu, FUNC(i80186_cpu_device::drq0_w));
	m_pit[0]->set_clk<1>(7000000);
	m_pit[0]->out_handler<1>().set(m_audiocpu, FUNC(i80186_cpu_device::drq1_w));
	m_pit[0]->set_clk<2>(7000000);
	m_pit[0]->out_handler<2>().set(FUNC(leland_80186_sound_device::pit0_2_w));

	PIT8254(config, m_pit[1], 0);
	m_pit[1]->set_clk<0>(7000000);
	m_pit[1]->out_handler<0>().set(FUNC(leland_80186_sound_device::pit1_0_w));
	m_pit[1]->set_clk<1>(7000000);
	m_pit[1]->out_handler<1>().set(FUNC(leland_80186_sound_device::pit1_1_w));
	m_pit[1]->set_clk<2>(7000000);

	PIT8254(config, m_pit[2], 0);
	m_pit[2]->set_clk<0>(7000000);
	m_pit[2]->out_handler<0>().set(FUNC(leland_80186_sound_device::pit1_2_w));
	m_pit[2]->set_clk<1>(7000000);
	m_pit[2]->set_clk<2>(7000000);

	GENERIC_LATCH_16(config, m_soundlatch);
}

void ataxx_80186_sound_device::device_add_mconfig(machine_config &config)
{
	I80186(config, m_audiocpu, 16_MHz_XTAL);
	m_audiocpu->set_addrmap(AS_PROGRAM, &ataxx_80186_sound_device::leland_80186_map_program);
	m_audiocpu->set_addrmap(AS_IO, &ataxx_80186_sound_device::ataxx_80186_map_io);
	m_audiocpu->chip_select_callback().set(FUNC(leland_80186_sound_device::peripheral_ctrl));
	m_audiocpu->tmrout0_handler().set(FUNC(leland_80186_sound_device::i80186_tmr0_w));

	SPEAKER(config, "speaker").front_center();
	for (int i = 0; i < 4; i++)
	{
		AD7524(config, m_dac[i], 0).add_route(ALL_OUTPUTS, "speaker", 0.2); // unknown DAC
		DAC_8BIT_BINARY_WEIGHTED(config, m_dacvol[i], 0); // unknown DAC
	}
	AD7533(config, "dac9", 0).add_route(ALL_OUTPUTS, "speaker", 1.0); // unknown DAC

	m_dacvol[0]->add_route(0, "dac1", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[0]->add_route(0, "dac1", -1.0, DAC_VREF_NEG_INPUT);
	m_dacvol[1]->add_route(0, "dac2", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[1]->add_route(0, "dac2", -1.0, DAC_VREF_NEG_INPUT);
	m_dacvol[2]->add_route(0, "dac3", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[2]->add_route(0, "dac3", -1.0, DAC_VREF_NEG_INPUT);
	m_dacvol[3]->add_route(0, "dac4", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[3]->add_route(0, "dac4", -1.0, DAC_VREF_NEG_INPUT);

	voltage_regulator_device &vref(VOLTAGE_REGULATOR(config, "vref", 0));
	vref.set_output(5.0);
	vref.add_route(0, "dac1vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac2vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac3vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac4vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac9", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac9", -1.0, DAC_VREF_NEG_INPUT);

	PIT8254(config, m_pit[0], 0);
	m_pit[0]->set_clk<0>(4000000);
	m_pit[0]->out_handler<0>().set(m_audiocpu, FUNC(i80186_cpu_device::drq0_w));
	m_pit[0]->set_clk<1>(4000000);
	m_pit[0]->out_handler<1>().set(m_audiocpu, FUNC(i80186_cpu_device::drq1_w));
	m_pit[0]->set_clk<2>(4000000);
	m_pit[0]->out_handler<2>().set(FUNC(leland_80186_sound_device::pit0_2_w));

	GENERIC_LATCH_16(config, m_soundlatch);
}

void wsf_80186_sound_device::device_add_mconfig(machine_config &config)
{
	I80186(config, m_audiocpu, 16_MHz_XTAL);
	m_audiocpu->set_addrmap(AS_PROGRAM, &wsf_80186_sound_device::leland_80186_map_program);
	m_audiocpu->set_addrmap(AS_IO, &wsf_80186_sound_device::ataxx_80186_map_io);
	m_audiocpu->chip_select_callback().set(FUNC(leland_80186_sound_device::peripheral_ctrl));
	m_audiocpu->tmrout0_handler().set(FUNC(leland_80186_sound_device::i80186_tmr0_w));
	m_audiocpu->tmrout1_handler().set(FUNC(leland_80186_sound_device::i80186_tmr1_w));

	SPEAKER(config, "speaker").front_center();
	for (int i = 0; i < 4; i++)
	{
		AD7524(config, m_dac[i], 0).add_route(ALL_OUTPUTS, "speaker", 0.2); // unknown DAC
		DAC_8BIT_BINARY_WEIGHTED(config, m_dacvol[i], 0); // unknown DAC
	}
	AD7533(config, "dac9", 0).add_route(ALL_OUTPUTS, "speaker", 1.0); // unknown DAC

	m_dacvol[0]->add_route(0, "dac1", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[0]->add_route(0, "dac1", -1.0, DAC_VREF_NEG_INPUT); // unknown DAC
	m_dacvol[1]->add_route(0, "dac2", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[1]->add_route(0, "dac2", -1.0, DAC_VREF_NEG_INPUT); // unknown DAC
	m_dacvol[2]->add_route(0, "dac3", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[2]->add_route(0, "dac3", -1.0, DAC_VREF_NEG_INPUT); // unknown DAC
	m_dacvol[3]->add_route(0, "dac4", 1.0, DAC_VREF_POS_INPUT);
	m_dacvol[3]->add_route(0, "dac4", -1.0, DAC_VREF_NEG_INPUT); // unknown DAC

	voltage_regulator_device &vref(VOLTAGE_REGULATOR(config, "vref", 0));
	vref.set_output(5.0);
	vref.add_route(0, "dac1vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac2vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac3vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac4vol", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac9", 1.0, DAC_VREF_POS_INPUT);
	vref.add_route(0, "dac9", -1.0, DAC_VREF_NEG_INPUT);

	/* sound hardware */
	YM2151(config, m_ymsnd, 4000000);
	m_ymsnd->add_route(0, "speaker", 0.40);
	m_ymsnd->add_route(1, "speaker", 0.40);

	PIT8254(config, m_pit[0], 0);
	m_pit[0]->set_clk<0>(4000000);
	m_pit[0]->out_handler<0>().set(m_audiocpu, FUNC(i80186_cpu_device::drq0_w));
	m_pit[0]->set_clk<1>(4000000);
	m_pit[0]->out_handler<1>().set(m_audiocpu, FUNC(i80186_cpu_device::drq1_w));
	m_pit[0]->set_clk<2>(4000000);
	m_pit[0]->out_handler<2>().set(FUNC(leland_80186_sound_device::pit0_2_w));

	GENERIC_LATCH_16(config, m_soundlatch);
}


void leland_80186_sound_device::leland_80186_map_program(address_map &map)
{
	map(0x00000, 0x03fff).mirror(0x1c000).ram();
	map(0x20000, 0xfffff).rom().region(":audiocpu", 0x20000);
}

void leland_80186_sound_device::ataxx_80186_map_io(address_map &map)
{
}

void redline_80186_sound_device::redline_80186_map_io(address_map &map)
{
	map(0x0000, 0xffff).w(FUNC(redline_80186_sound_device::redline_dac_w));
}


void leland_80186_sound_device::leland_80186_map_io(address_map &map)
{
	map(0x0000, 0xffff).w(FUNC(leland_80186_sound_device::dac_w));
}

/*************************************
 *
 *  Sound initialization
 *
 *************************************/

void leland_80186_sound_device::device_start()
{
	// register for savestates
	save_item(NAME(m_peripheral));
	save_item(NAME(m_last_control));
	save_item(NAME(m_clock_active));
	save_item(NAME(m_clock_tick));
	save_item(NAME(m_sound_command));
	save_item(NAME(m_sound_response));
	save_item(NAME(m_ext_start));
	save_item(NAME(m_ext_stop));
	save_item(NAME(m_ext_active));

	// zerofill
	m_peripheral = 0;
	m_last_control = 0;
	m_clock_active = 0;
	m_clock_tick = 0;
	m_sound_command = 0;
	m_sound_response = 0;
	m_ext_start = 0;
	m_ext_stop = 0;
	m_ext_active = 0;
	m_ext_base = nullptr;

	/* determine which sound hardware is installed */
	if (m_type == TYPE_WSF)
		m_ext_base = machine().root_device().memregion("dac")->base();
}

void leland_80186_sound_device::device_reset()
{
	m_last_control = 0xf8;
	m_clock_active = 0;
	m_clock_tick = 0;
	m_ext_start = 0;
	m_ext_stop = 0;
	m_ext_active = 0;
}

DEFINE_DEVICE_TYPE(LELAND_80186, leland_80186_sound_device, "leland_80186_sound", "80186 DAC (Leland)")

leland_80186_sound_device::leland_80186_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: leland_80186_sound_device(mconfig, LELAND_80186, tag, owner, clock)
{
	m_type = TYPE_LELAND;
}

leland_80186_sound_device::leland_80186_sound_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, type, tag, owner, clock)
	, m_soundlatch(*this, "soundlatch")
	, m_dac(*this, "dac%u", 1U)
	, m_dac9(*this, "dac9")
	, m_dacvol(*this, "dac%uvol", 1U)
	, m_pit(*this, "pit%u", 0U)
	, m_audiocpu(*this, "audiocpu")
	, m_ymsnd(*this, "ymsnd")
	, m_master(*this, ":master")
{
}

DEFINE_DEVICE_TYPE(REDLINE_80186, redline_80186_sound_device, "redline_80186_sound", "80186 DAC (Redline Racer)")

redline_80186_sound_device::redline_80186_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: leland_80186_sound_device(mconfig, REDLINE_80186, tag, owner, clock)
{
	m_type = TYPE_REDLINE;
}

DEFINE_DEVICE_TYPE(ATAXX_80186, ataxx_80186_sound_device, "ataxx_80186_sound", "80186 DAC (Ataxx)")

ataxx_80186_sound_device::ataxx_80186_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: leland_80186_sound_device(mconfig, ATAXX_80186, tag, owner, clock)
{
	m_type = TYPE_ATAXX;
}

DEFINE_DEVICE_TYPE(WSF_80186, wsf_80186_sound_device, "wsf_80186_sound", "80186 DAC (WSF)")

wsf_80186_sound_device::wsf_80186_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: leland_80186_sound_device(mconfig, WSF_80186, tag, owner, clock)
{
	m_type = TYPE_WSF;
}

WRITE16_MEMBER(leland_80186_sound_device::peripheral_ctrl)
{
	switch (offset)
	{
		case 2:
			m_peripheral = data;
			break;

		case 4:
		{
			uint32_t temp = (m_peripheral & 0xffc0) << 4;
			if (data & 0x0040)
			{
				m_audiocpu->space(AS_PROGRAM).install_readwrite_handler(temp, temp + 0x2ff, read16_delegate(FUNC(leland_80186_sound_device::peripheral_r), this), write16_delegate(FUNC(leland_80186_sound_device::peripheral_w), this));
			}
			else
			{
				temp &= 0xffff;
				m_audiocpu->space(AS_IO).install_readwrite_handler(temp, temp + 0x2ff, read16_delegate(FUNC(leland_80186_sound_device::peripheral_r), this), write16_delegate(FUNC(leland_80186_sound_device::peripheral_w), this));
			}
			break;
		}

		default:
			break;
	}
}

/*************************************
 *
 *  External 80186 control
 *
 *************************************/

WRITE8_MEMBER( leland_80186_sound_device::leland_80186_control_w )
{
	/* see if anything changed */
	int diff = (m_last_control ^ data) & 0xf8;
	if (diff == 0)
		return;
	m_last_control = data;

	if (LOG_COMM)
	{
		logerror("%s:80186 control = %02X", machine().describe_context(), data);
		if (!(data & 0x80)) logerror("  /RESET");
		if (!(data & 0x40)) logerror("  ZNMI");
		if (!(data & 0x20)) logerror("  INT0");
		if (!(data & 0x10)) logerror("  /TEST");
		if (!(data & 0x08)) logerror("  INT1");
		logerror("\n");
	}

	/* /RESET */
	m_audiocpu->set_input_line(INPUT_LINE_RESET, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
	m_audiocpu->set_input_line(INPUT_LINE_TEST, (data & 0x10) ? CLEAR_LINE : ASSERT_LINE);

	/* /NMI */
/*  If the master CPU doesn't get a response by the time it's ready to send
    the next command, it uses an NMI to force the issue; unfortunately, this
    seems to really screw up the sound system. It turns out it's better to
    just wait for the original interrupt to occur naturally */
/*  m_audiocpu->set_input_line(INPUT_LINE_NMI, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE);*/

	/* INT0 */
	m_audiocpu->int0_w(data & 0x20);
	/* INT1 */
	m_audiocpu->int1_w(data & 0x08);
	/* handle reset here */
	if ((diff & 0x80) && (data & 0x80))
		reset();
}



/*************************************
 *
 *  Sound command handling
 *
 *************************************/

WRITE8_MEMBER( leland_80186_sound_device::leland_80186_command_lo_w )
{
	if (LOG_COMM) logerror("%s:Write sound command latch lo = %02X\n", machine().describe_context(), data);
	m_sound_command = (m_sound_command & 0xff00) | data;
	m_soundlatch->write(space, offset, m_sound_command);
}


WRITE8_MEMBER( leland_80186_sound_device::leland_80186_command_hi_w )
{
	if (LOG_COMM) logerror("%s:Write sound command latch hi = %02X\n", machine().describe_context(), data);
	m_sound_command = (m_sound_command & 0x00ff) | (data << 8);
	m_soundlatch->write(space, offset, m_sound_command);
}




/*************************************
 *
 *  Sound response handling
 *
 *************************************/

void leland_80186_sound_device::delayed_response_r(void *ptr, int param)
{
	int checkpc = param;
	int pc = m_master->pc();
	int oldaf = m_master->state_int(Z80_AF);

	/* This is pretty cheesy, but necessary. Since the CPUs run in round-robin order,
	   synchronizing on the write to this register from the slave side does nothing.
	   In order to make sure the master CPU get the real response, we synchronize on
	   the read. However, the value we returned the first time around may not be
	   accurate, so after the system has synced up, we go back into the master CPUs
	   state and put the proper value into the A register. */
	if (pc == checkpc)
	{
		if (LOG_COMM) logerror("(Updated sound response latch to %02X)\n", m_sound_response);

		oldaf = (oldaf & 0x00ff) | (m_sound_response << 8);
		m_master->set_state_int(Z80_AF, oldaf);
	}
	else if(LOG_COMM)
		logerror("ERROR: delayed_response_r - current PC = %04X, checkPC = %04X\n", pc, checkpc);
}


READ8_MEMBER( leland_80186_sound_device::leland_80186_response_r )
{
	offs_t pc = m_master->pcbase();

	if (LOG_COMM) logerror("%04X:Read sound response latch = %02X\n", pc, m_sound_response);

	/* synchronize the response */
	machine().scheduler().synchronize(timer_expired_delegate(FUNC(leland_80186_sound_device::delayed_response_r), this), pc + 2);
	return m_sound_response;
}



/*************************************
 *
 *  Low-level DAC I/O
 *
 *************************************/

WRITE16_MEMBER( leland_80186_sound_device::dac_w )
{
	int dac = offset & 7;

	/* handle value changes */
	if (ACCESSING_BITS_0_7)
	{
		m_dac[dac]->write(data & 0xff);

		set_clock_line(dac, 0);
	}

	/* handle volume changes */
	if (ACCESSING_BITS_8_15)
	{
		m_dacvol[dac]->write(data >> 8);
	}
}


WRITE16_MEMBER( redline_80186_sound_device::redline_dac_w )
{
	dac_w(space, (offset >> 8) & 7, (data & 0xff) | (offset << 8), 0xffff);
}

WRITE16_MEMBER( leland_80186_sound_device::ataxx_dac_control )
{
	if (ACCESSING_BITS_0_7)
	{
		/* handle common offsets */
		switch (offset)
		{
		case 0x00:
		case 0x01:
		case 0x02:
			dac_w(space, offset, data, 0x00ff);
			return;
		case 0x03:
			m_dacvol[0]->write((data & 7) << 5);
			m_dacvol[1]->write(((data >> 3) & 7) << 5);
			m_dacvol[2]->write(((data >> 6) & 3) << 6);
			return;
		case 0x21:
			dac_w(space, 3, data, mem_mask);
			return;
		}
	}

	/* if we have a YM2151 (and an external DAC), handle those offsets */
	switch (m_type)
	{
	case TYPE_WSF:
		switch (offset)
		{
		case 0x04:
			m_ext_active = 1;
			if (LOG_EXTERN) logerror("External DAC active\n");
			return;
		case 0x05:
			m_ext_active = 0;
			if (LOG_EXTERN) logerror("External DAC inactive\n");
			return;
		case 0x06:
			m_ext_start >>= 4;
			COMBINE_DATA(&m_ext_start);
			m_ext_start <<= 4;
			if (LOG_EXTERN) logerror("External DAC start = %05X\n", m_ext_start);
			return;
		case 0x07:
			m_ext_stop >>= 4;
			COMBINE_DATA(&m_ext_stop);
			m_ext_stop <<= 4;
			if (LOG_EXTERN) logerror("External DAC stop = %05X\n", m_ext_stop);
			return;
		}
		break;
	}

	logerror("%s:Unexpected peripheral write %d/%02X = %02X\n", machine().describe_context(), 5, offset, data);
}



/*************************************
 *
 *  Peripheral chip dispatcher
 *
 *************************************/

READ16_MEMBER( leland_80186_sound_device::peripheral_r )
{
	int select = offset / 0x40;
	offset &= 0x3f;

	switch (select)
	{
		case 0:
			/* we have to return 0 periodically so that they handle interrupts */
			//if ((++m_clock_tick & 7) == 0)
			//  return 0;

			/* if we've filled up all the active channels, we can give this CPU a rest */
			/* until the next interrupt */
			if (m_type != TYPE_REDLINE)
				return ((m_clock_active >> 1) & 0x3e);
			else
				return ((m_clock_active << 1) & 0x7e);

		case 1:
			if (LOG_COMM) logerror("%s:Read sound command latch = %02X\n", machine().describe_context(), m_soundlatch->read(space, offset));
			return m_soundlatch->read(space, offset);

		case 2:
			if (ACCESSING_BITS_0_7)
				return m_pit[0]->read(offset & 3);
			break;

		case 3:
			if (m_type <= TYPE_REDLINE)
			{
				if (ACCESSING_BITS_0_7)
					return m_pit[1]->read(offset & 3);
			}
			else if (m_type == TYPE_WSF)
				return m_ymsnd->read(space, offset);
			break;

		case 4:
			if (m_type == TYPE_REDLINE)
			{
				if (ACCESSING_BITS_0_7)
					return m_pit[2]->read(offset & 3);
			}
			else
				logerror("%s:Unexpected peripheral read %d/%02X\n", machine().describe_context(), select, offset*2);
			break;

		default:
			logerror("%s:Unexpected peripheral read %d/%02X\n", machine().describe_context(), select, offset*2);
			break;
	}
	return 0xffff;
}


WRITE16_MEMBER( leland_80186_sound_device::peripheral_w )
{
	int select = offset / 0x40;
	offset &= 0x3f;

	switch (select)
	{
		case 1:
			if (LOG_COMM) logerror("%s:Write sound response latch = %02X\n", machine().describe_context(), data);
			m_sound_response = data;
			break;

		case 2:
			if (ACCESSING_BITS_0_7)
				m_pit[0]->write(offset & 3, data);
			break;

		case 3:
			if (m_type <= TYPE_REDLINE)
			{
				if (ACCESSING_BITS_0_7)
					m_pit[1]->write(offset & 3, data);
			}
			else if(m_type == TYPE_WSF)
				m_ymsnd->write(space, offset, data);
			break;

		case 4:
			if (m_type == TYPE_REDLINE)
			{
				if (ACCESSING_BITS_0_7)
					m_pit[2]->write(offset & 3, data);
			}
			else if (mem_mask == 0xffff)
			{
				m_dac9->write(data);
				set_clock_line(6, 0);
			}
			break;

		case 5: /* Ataxx/WSF/Indy Heat only */
			if (m_type > TYPE_REDLINE)
				ataxx_dac_control(space, offset, data, mem_mask);
			break;

		default:
			logerror("%s:Unexpected peripheral write %d/%02X = %02X\n", machine().describe_context(), select, offset, data);
			break;
	}
}



/*************************************
 *
 *  Game-specific handlers
 *
 *************************************/

WRITE8_MEMBER( leland_80186_sound_device::ataxx_80186_control_w )
{
	/* compute the bit-shuffled variants of the bits and then write them */
	int modified =  ((data & 0x01) << 7) |
					((data & 0x02) << 5) |
					((data & 0x04) << 3) |
					((data & 0x08) << 1);
	leland_80186_control_w(space, offset, modified);
}