1 // license:BSD-3-Clause
2 // copyright-holders:R. Belmont
3 /***************************************************************************
4
5 Sega Model 1 sound board (68000 + 2x 315-5560 "MultiPCM")
6
7 used for Model 1 and early Model 2 games
8
9 ***************************************************************************/
10
11 #include "emu.h"
12 #include "audio/segam1audio.h"
13
14 #include "machine/clock.h"
15 #include "speaker.h"
16
segam1audio_map(address_map & map)17 void segam1audio_device::segam1audio_map(address_map &map)
18 {
19 map(0x000000, 0x03ffff).rom();
20 map(0x080000, 0x09ffff).rom().region("sndcpu", 0x20000); // mirror of upper ROM socket
21 map(0xc20000, 0xc20003).rw(m_uart, FUNC(i8251_device::read), FUNC(i8251_device::write)).umask16(0x00ff);
22 map(0xc40000, 0xc40007).rw(m_multipcm_1, FUNC(multipcm_device::read), FUNC(multipcm_device::write)).umask16(0x00ff);
23 map(0xc40012, 0xc40013).nopw();
24 map(0xc50000, 0xc50001).w(FUNC(segam1audio_device::m1_snd_mpcm_bnk1_w));
25 map(0xc60000, 0xc60007).rw(m_multipcm_2, FUNC(multipcm_device::read), FUNC(multipcm_device::write)).umask16(0x00ff);
26 map(0xc70000, 0xc70001).w(FUNC(segam1audio_device::m1_snd_mpcm_bnk2_w));
27 map(0xd00000, 0xd00007).rw(m_ym, FUNC(ym3438_device::read), FUNC(ym3438_device::write)).umask16(0x00ff);
28 map(0xf00000, 0xf0ffff).ram();
29 }
30
mpcm1_map(address_map & map)31 void segam1audio_device::mpcm1_map(address_map &map)
32 {
33 map(0x000000, 0x0fffff).rom();
34 map(0x100000, 0x1fffff).bankr(m_mpcmbank1);
35 }
36
mpcm2_map(address_map & map)37 void segam1audio_device::mpcm2_map(address_map &map)
38 {
39 map(0x000000, 0x0fffff).rom();
40 map(0x100000, 0x1fffff).bankr(m_mpcmbank2);
41 }
42
43 //**************************************************************************
44 // GLOBAL VARIABLES
45 //**************************************************************************
46
47 DEFINE_DEVICE_TYPE(SEGAM1AUDIO, segam1audio_device, "segam1audio", "Sega Model 1 Sound Board")
48
49 //-------------------------------------------------
50 // device_add_mconfig - add device configuration
51 //-------------------------------------------------
52
device_add_mconfig(machine_config & config)53 void segam1audio_device::device_add_mconfig(machine_config &config)
54 {
55 M68000(config, m_audiocpu, 10000000); // verified on real h/w
56 m_audiocpu->set_addrmap(AS_PROGRAM, &segam1audio_device::segam1audio_map);
57
58 SPEAKER(config, "lspeaker").front_left();
59 SPEAKER(config, "rspeaker").front_right();
60
61 YM3438(config, m_ym, 8000000);
62 m_ym->add_route(0, "lspeaker", 0.60);
63 m_ym->add_route(1, "rspeaker", 0.60);
64
65 MULTIPCM(config, m_multipcm_1, 8000000);
66 m_multipcm_1->set_addrmap(0, &segam1audio_device::mpcm1_map);
67 m_multipcm_1->add_route(0, "lspeaker", 1.0);
68 m_multipcm_1->add_route(1, "rspeaker", 1.0);
69
70 MULTIPCM(config, m_multipcm_2, 8000000);
71 m_multipcm_2->set_addrmap(0, &segam1audio_device::mpcm2_map);
72 m_multipcm_2->add_route(0, "lspeaker", 1.0);
73 m_multipcm_2->add_route(1, "rspeaker", 1.0);
74
75 I8251(config, m_uart, 8000000); // T82C51, clock unknown
76 m_uart->rxrdy_handler().set_inputline(m_audiocpu, M68K_IRQ_2);
77 m_uart->txd_handler().set(FUNC(segam1audio_device::output_txd));
78
79 clock_device &uart_clock(CLOCK(config, "uart_clock", 500000)); // 16 times 31.25MHz (standard Sega/MIDI sound data rate)
80 uart_clock.signal_handler().set(m_uart, FUNC(i8251_device::write_txc));
81 uart_clock.signal_handler().append(m_uart, FUNC(i8251_device::write_rxc));
82 }
83
84 //**************************************************************************
85 // LIVE DEVICE
86 //**************************************************************************
87
88 //-------------------------------------------------
89 // segam1audio_device - constructor
90 //-------------------------------------------------
91
segam1audio_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)92 segam1audio_device::segam1audio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
93 device_t(mconfig, SEGAM1AUDIO, tag, owner, clock),
94 m_audiocpu(*this, "sndcpu"),
95 m_multipcm_1(*this, "pcm1"),
96 m_multipcm_2(*this, "pcm2"),
97 m_ym(*this, "ymsnd"),
98 m_uart(*this, "uart"),
99 m_multipcm1_region(*this, "pcm1"),
100 m_multipcm2_region(*this, "pcm2"),
101 m_mpcmbank1(*this, "m1pcm1_bank"),
102 m_mpcmbank2(*this, "m1pcm2_bank"),
103 m_rxd_handler(*this)
104 {
105 }
106
107 //-------------------------------------------------
108 // device_start - device-specific startup
109 //-------------------------------------------------
110
device_start()111 void segam1audio_device::device_start()
112 {
113 m_rxd_handler.resolve_safe();
114 m_mpcmbank1->configure_entries(0, 4, m_multipcm1_region->base(), 0x100000);
115 m_mpcmbank2->configure_entries(0, 4, m_multipcm2_region->base(), 0x100000);
116 }
117
118 //-------------------------------------------------
119 // device_reset - device-specific reset
120 //-------------------------------------------------
121
device_reset()122 void segam1audio_device::device_reset()
123 {
124 m_uart->write_cts(0);
125 }
126
m1_snd_mpcm_bnk1_w(uint16_t data)127 void segam1audio_device::m1_snd_mpcm_bnk1_w(uint16_t data)
128 {
129 m_mpcmbank1->set_entry(data & 3);
130 }
131
m1_snd_mpcm_bnk2_w(uint16_t data)132 void segam1audio_device::m1_snd_mpcm_bnk2_w(uint16_t data)
133 {
134 m_mpcmbank2->set_entry(data & 3);
135 }
136
WRITE_LINE_MEMBER(segam1audio_device::write_txd)137 WRITE_LINE_MEMBER(segam1audio_device::write_txd)
138 {
139 m_uart->write_rxd(state);
140 }
141
WRITE_LINE_MEMBER(segam1audio_device::output_txd)142 WRITE_LINE_MEMBER(segam1audio_device::output_txd)
143 {
144 m_rxd_handler(state);
145 }
146