1 // license:BSD-3-Clause
2 // copyright-holders:Angelo Salese,Takahiro Nogi
3 /***************************************************************************
4
5 Nichibutsu sound HW
6
7 Shared component between niyanpai.cpp and csplayh5.cpp
8
9 Uses a TMPZ84C011 with YM3812 and two DACs
10
11 TODO:
12 - DVD sound routing in here
13
14 ***************************************************************************/
15
16 #include "emu.h"
17 #include "nichisnd.h"
18
19
20
21 //**************************************************************************
22 // GLOBAL VARIABLES
23 //**************************************************************************
24
25 // device type definition
26 DEFINE_DEVICE_TYPE(NICHISND, nichisnd_device, "nichisnd", "Nichibutsu Sound Device")
27
28
29 //**************************************************************************
30 // LIVE DEVICE
31 //**************************************************************************
32
33 //-------------------------------------------------
34 // nichisnd_device - constructor
35 //-------------------------------------------------
36
nichisnd_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)37 nichisnd_device::nichisnd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
38 : device_t(mconfig, NICHISND, tag, owner, clock),
39 m_soundlatch(*this, "soundlatch"),
40 m_sound_rom(*this, "audiorom")
41 {
42 }
43
nichisnd_map(address_map & map)44 void nichisnd_device::nichisnd_map(address_map &map)
45 {
46 map(0x0000, 0x77ff).rom().region("audiorom", 0);
47 map(0x7800, 0x7fff).ram();
48 map(0x8000, 0xffff).bankr("soundbank");
49 }
50
nichisnd_io_map(address_map & map)51 void nichisnd_device::nichisnd_io_map(address_map &map)
52 {
53 map(0x80, 0x81).mirror(0xff00).w("ymsnd", FUNC(ym3812_device::write));
54 }
55
56
soundbank_w(uint8_t data)57 void nichisnd_device::soundbank_w(uint8_t data)
58 {
59 membank("soundbank")->set_entry(data & 0x03);
60 }
61
soundlatch_clear_w(uint8_t data)62 void nichisnd_device::soundlatch_clear_w(uint8_t data)
63 {
64 if (!(data & 0x01)) m_soundlatch->clear_w();
65 }
66
67
68 //-------------------------------------------------
69 // add_device_mconfig - device-specific machine
70 // configuration addiitons
71 //-------------------------------------------------
72
73 static const z80_daisy_config daisy_chain[] =
74 {
75 TMPZ84C011_DAISY_INTERNAL,
76 { nullptr }
77 };
78
79
80
device_add_mconfig(machine_config & config)81 void nichisnd_device::device_add_mconfig(machine_config &config)
82 {
83 tmpz84c011_device& audiocpu(TMPZ84C011(config, "audiocpu", 8000000)); /* TMPZ84C011, 8.00 MHz */
84 audiocpu.set_daisy_config(daisy_chain);
85 audiocpu.set_addrmap(AS_PROGRAM, &nichisnd_device::nichisnd_map);
86 audiocpu.set_addrmap(AS_IO, &nichisnd_device::nichisnd_io_map);
87 audiocpu.in_pd_callback().set(m_soundlatch, FUNC(generic_latch_8_device::read));
88 audiocpu.out_pa_callback().set(FUNC(nichisnd_device::soundbank_w));
89 audiocpu.out_pb_callback().set("dac1", FUNC(dac_byte_interface::data_w));
90 audiocpu.out_pc_callback().set("dac2", FUNC(dac_byte_interface::data_w));
91 audiocpu.out_pe_callback().set(FUNC(nichisnd_device::soundlatch_clear_w));
92 audiocpu.zc0_callback().set("audiocpu", FUNC(tmpz84c011_device::trg3));
93
94 /* sound hardware */
95 SPEAKER(config, "speaker").front_center();
96
97 GENERIC_LATCH_8(config, m_soundlatch);
98
99 YM3812(config, "ymsnd", 4000000).add_route(ALL_OUTPUTS, "speaker", 1.0);
100
101 DAC_8BIT_R2R(config, "dac1", 0).add_route(ALL_OUTPUTS, "speaker", 0.37); // unknown DAC
102 DAC_8BIT_R2R(config, "dac2", 0).add_route(ALL_OUTPUTS, "speaker", 0.37); // unknown DAC
103 }
104
105
106 //-------------------------------------------------
107 // device_start - device-specific startup
108 //-------------------------------------------------
109
device_start()110 void nichisnd_device::device_start()
111 {
112 uint8_t *SNDROM = m_sound_rom;
113
114 // sound program patch
115 SNDROM[0x0213] = 0x00; // DI -> NOP
116
117 // initialize sound rom bank
118 membank("soundbank")->configure_entries(0, 3, m_sound_rom + 0x8000, 0x8000);
119 membank("soundbank")->set_entry(0);
120 }
121
122
123 //-------------------------------------------------
124 // device_reset - device-specific reset
125 //-------------------------------------------------
126
device_reset()127 void nichisnd_device::device_reset()
128 {
129 }
130
131
132 //**************************************************************************
133 // READ/WRITE HANDLERS
134 //**************************************************************************
135
136 // use this to connect to the sound board
sound_host_command_w(uint8_t data)137 void nichisnd_device::sound_host_command_w(uint8_t data)
138 {
139 m_soundlatch->write(data);
140 }
141