summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/bally.h
blob: 6d6fe670333091f2f3f0614229a2239bbb1cf19f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
// license:BSD-3-Clause
// copyright-holders:Mike Harris
/***************************************************************************

    bally.h

    Functions to emulate the various Bally pinball sound boards.

***************************************************************************/
#ifndef MAME_AUDIO_BALLY_H
#define MAME_AUDIO_BALLY_H

#pragma once


#include "cpu/m6800/m6800.h"
#include "cpu/m6800/m6801.h"
#include "cpu/m6809/m6809.h"
#include "machine/6821pia.h"
#include "machine/timer.h"
#include "sound/ay8910.h"
#include "sound/dac.h"
#include "sound/discrete.h"
#include "sound/flt_rc.h"
#include "sound/hc55516.h"
#include "sound/tms5220.h"



//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

DECLARE_DEVICE_TYPE(BALLY_AS2888,           bally_as2888_device)
DECLARE_DEVICE_TYPE(BALLY_AS3022,           bally_as3022_device)
DECLARE_DEVICE_TYPE(BALLY_SOUNDS_PLUS,      bally_sounds_plus_device)
DECLARE_DEVICE_TYPE(BALLY_CHEAP_SQUEAK,     bally_cheap_squeak_device)
DECLARE_DEVICE_TYPE(BALLY_SQUAWK_N_TALK,    bally_squawk_n_talk_device)
DECLARE_DEVICE_TYPE(BALLY_SQUAWK_N_TALK_AY, bally_squawk_n_talk_ay_device)


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************

// ======================> bally_as2888_device

class bally_as2888_device : public device_t, public device_mixer_interface
{
public:
	bally_as2888_device(
			const machine_config &mconfig,
			const char *tag,
			device_t *owner,
			uint32_t clock = 0) :
		bally_as2888_device(mconfig, BALLY_AS2888, tag, owner)
	{ }

	// read/write
	void sound_select(uint8_t data);
	DECLARE_WRITE_LINE_MEMBER(sound_int);

	void as2888_map(address_map &map);

protected:
	bally_as2888_device(
			const machine_config &mconfig,
			device_type type,
			const char *tag,
			device_t *owner) :
		device_t(mconfig, type, tag, owner, 0),
		device_mixer_interface(mconfig, *this),
		m_snd_prom(*this, "sound"),
		m_discrete(*this, "discrete"),
		m_timer_s_freq(*this, "timer_s_freq"),
		m_snd_sustain_timer(*this, "timer_as2888")
	{ }

	// device-level overrides
	virtual void device_add_mconfig(machine_config &config) override;
	virtual void device_start() override;

private:
	uint8_t m_sound_select;
	uint8_t m_snd_sel;
	uint8_t m_snd_tone_gen;
	uint8_t m_snd_div;
	required_region_ptr<uint8_t> m_snd_prom;
	required_device<discrete_sound_device> m_discrete;
	required_device<timer_device> m_timer_s_freq;
	required_device<timer_device> m_snd_sustain_timer;


	// internal communications
	TIMER_CALLBACK_MEMBER(sound_select_sync);
	TIMER_CALLBACK_MEMBER(sound_int_sync);
	TIMER_DEVICE_CALLBACK_MEMBER(timer_s);
	TIMER_DEVICE_CALLBACK_MEMBER(timer_as2888);
};


// ======================> bally_as3022_device

class bally_as3022_device : public device_t, public device_mixer_interface
{
public:
	bally_as3022_device(
			const machine_config &mconfig,
			const char *tag,
			device_t *owner,
			uint32_t clock = 3'579'545) :
		bally_as3022_device(mconfig, BALLY_AS3022, tag, owner, clock)
	{ }

	// read/write
	DECLARE_INPUT_CHANGED_MEMBER(sw1);
	void sound_select(uint8_t data);
	DECLARE_WRITE_LINE_MEMBER(sound_int);

	void as3022_map(address_map &map);

protected:
	bally_as3022_device(
			const machine_config &mconfig,
			device_type type,
			const char *tag,
			device_t *owner,
			uint32_t clock) :
		device_t(mconfig, type, tag, owner, clock),
		device_mixer_interface(mconfig, *this),
		m_cpu(*this, "cpu"),
		m_pia(*this, "pia"),
		m_ay_filters(*this, "ay_filter%u", 0),
		m_ay(*this, "ay"),
		m_mc3417_filter(*this, "mc3417_filter"),
		m_mc3417(*this, "mc3417")
	{ }

	// device-level overrides
	virtual void device_add_mconfig(machine_config &config) override;
	virtual void device_start() override;
	virtual ioport_constructor device_input_ports() const override;

	// devices
	// The schematics list an optional 555, but it never seemed to be used
	required_device<m6808_cpu_device> m_cpu;
	required_device<pia6821_device> m_pia;
	required_device_array<filter_rc_device, 3> m_ay_filters;
	required_device<ay8910_device> m_ay;
	optional_device<filter_rc_device> m_mc3417_filter;
	optional_device<mc3417_device> m_mc3417;

	// overwridden by children
	void pia_portb_w(uint8_t data);

private:
	bool m_bc1;
	bool m_bdir;
	uint8_t m_sound_select;
	uint8_t m_ay_data;

	// internal communications
	TIMER_CALLBACK_MEMBER(sound_select_sync);
	TIMER_CALLBACK_MEMBER(sound_int_sync);
	uint8_t pia_porta_r();
	void pia_porta_w(uint8_t data);
	DECLARE_WRITE_LINE_MEMBER(pia_cb2_w);
	DECLARE_WRITE_LINE_MEMBER(pia_irq_w);
	uint8_t ay_io_r();

	void update_ay_bus();
};


// ======================> bally_sounds_plus_device
class bally_sounds_plus_device : public bally_as3022_device
{
public:
	bally_sounds_plus_device(
			const machine_config &mconfig,
			const char *tag,
			device_t *owner,
			uint32_t clock = 3'579'545) :
		bally_as3022_device(mconfig, BALLY_SOUNDS_PLUS, tag, owner, clock)
	{ }

	void sounds_plus_map(address_map &map);

protected:
	// device-level overrides
	virtual void device_add_mconfig(machine_config &config) override;

private:
	// internal communications
	void vocalizer_pia_portb_w(uint8_t data);
};


// ======================> bally_cheap_squeak_device

class bally_cheap_squeak_device : public device_t, public device_mixer_interface
{
public:
	bally_cheap_squeak_device(
			const machine_config &mconfig,
			const char *tag,
			device_t *owner,
			uint32_t clock = 3'579'545) :
		bally_cheap_squeak_device(mconfig, BALLY_CHEAP_SQUEAK, tag, owner, clock)
	{ }

	auto sound_ack_w_handler() { return m_sound_ack_w_handler.bind(); }

	// read/write
	DECLARE_INPUT_CHANGED_MEMBER(sw1);
	void sound_select(uint8_t data);
	DECLARE_WRITE_LINE_MEMBER(sound_int);

	void cheap_squeak_map(address_map &map);

protected:
	bally_cheap_squeak_device(
			const machine_config &mconfig,
			device_type type,
			const char *tag,
			device_t *owner,
			uint32_t clock) :
		device_t(mconfig, type, tag, owner, clock),
		device_mixer_interface(mconfig, *this),
		m_cpu(*this, "cpu"),
		m_dac(*this, "dac"),
		m_sound_ack_w_handler(*this)
	{ }

	// device-level overrides
	virtual void device_add_mconfig(machine_config &config) override;
	virtual void device_start() override;
	virtual ioport_constructor device_input_ports() const override;

	// devices
	required_device<m6803_cpu_device> m_cpu;
	required_device<dac_byte_interface> m_dac;

private:
	uint8_t m_sound_select;
	bool m_sound_int;
	bool m_sound_ack;

	devcb_write_line m_sound_ack_w_handler;

	// internal communications
	TIMER_CALLBACK_MEMBER(sound_select_sync);
	TIMER_CALLBACK_MEMBER(sound_int_sync);
	void out_p1_cb(uint8_t data);
	uint8_t in_p2_cb();
	void out_p2_cb(uint8_t data);

	void update_led();
};

// ======================> bally_squawk_n_talk_device

// This board comes in different configurations, with or without the DAC and/or AY8910.

class bally_squawk_n_talk_device : public device_t, public device_mixer_interface
{
public:
	bally_squawk_n_talk_device(
			const machine_config &mconfig,
			const char *tag,
			device_t *owner,
			uint32_t clock = 3'579'545) :
		bally_squawk_n_talk_device(mconfig, BALLY_SQUAWK_N_TALK, tag, owner, clock)
	{ }

	// read/write
	DECLARE_INPUT_CHANGED_MEMBER(sw1);
	void sound_select(uint8_t data);
	DECLARE_WRITE_LINE_MEMBER(sound_int);

	void squawk_n_talk_map(address_map &map);

protected:
	bally_squawk_n_talk_device(
			const machine_config &mconfig,
			device_type type,
			const char *tag,
			device_t *owner,
			uint32_t clock) :
		device_t(mconfig, type, tag, owner, clock),
		device_mixer_interface(mconfig, *this),
		m_cpu(*this, "cpu"),
		m_pia1(*this, "pia1"),
		m_pia2(*this, "pia2"),
		m_dac_filter(*this, "dac_filter"),
		m_dac(*this, "dac"),
		m_speech_filter(*this, "speech_filter"),
		m_tms5200(*this, "tms5200"),
		m_ay_filters(*this, "ay_filter%u", 0),
		m_ay(*this, "ay")
	{ }

	// device-level overrides
	virtual void device_add_mconfig(machine_config &config) override;
	virtual void device_start() override;
	virtual ioport_constructor device_input_ports() const override;

	// devices
	required_device<m6802_cpu_device> m_cpu;
	required_device<pia6821_device> m_pia1;
	required_device<pia6821_device> m_pia2;
	required_device<filter_rc_device> m_dac_filter;
	required_device<dac_byte_interface> m_dac;
	required_device<filter_rc_device> m_speech_filter;
	required_device<tms5200_device> m_tms5200;
	optional_device_array<filter_rc_device, 3> m_ay_filters;
	optional_device<ay8910_device> m_ay;

	uint8_t m_sound_select;

	uint8_t pia2_porta_r();

private:
	// internal communications
	TIMER_CALLBACK_MEMBER(sound_select_sync);
	TIMER_CALLBACK_MEMBER(sound_int_sync);
	void pia1_portb_w(uint8_t data);
	DECLARE_WRITE_LINE_MEMBER(pia2_ca2_w);
	DECLARE_WRITE_LINE_MEMBER(pia_irq_w);
};


class bally_squawk_n_talk_ay_device : public bally_squawk_n_talk_device
{
public:
	bally_squawk_n_talk_ay_device(
			const machine_config &mconfig,
			const char *tag,
			device_t *owner,
			uint32_t clock = 3'579'545) :
		bally_squawk_n_talk_device(mconfig, BALLY_SQUAWK_N_TALK_AY, tag, owner, clock)
	{ }

protected:
	// device-level overrides
	virtual void device_add_mconfig(machine_config &config) override;
	virtual void device_start() override;

	uint8_t pia2_porta_r();

private:
	bool m_bc1;
	bool m_bdir;
	uint8_t m_ay_data;

	void pia2_porta_w(uint8_t data);
	void pia2_portb_w(uint8_t data);
	DECLARE_WRITE_LINE_MEMBER(pia2_cb2_w);
	uint8_t ay_io_r();

	void update_ay_bus();
};


#endif // MAME_AUDIO_BALLY_H