summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/circus.c
blob: 951a039f272c77575cc0d3a56ab5b3b549e8c091 (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
#include "driver.h"
#include "sound/samples.h"
#include "circus.h"

int circus_game;

static const char *circus_sample_names[] =
{
	"*circus",
	"pop.wav",
	"miss.wav",
	"bounce.wav",
	0
};

struct Samplesinterface circus_samples_interface =
{
	3,	/* 3 channels */
	circus_sample_names
};

static const char *crash_sample_names[] =
{
	"*crash",
	"crash.wav",
	0
};

struct Samplesinterface crash_samples_interface =
{
	1,	/* 1 channel */
	crash_sample_names
};

static const char *ripcord_sample_names[] =
{
	"*ripcord",
	"splash.wav",
	"scream.wav",
	"chute.wav",
	"whistle.wav",
	0
};

struct Samplesinterface ripcord_samples_interface =
{
	4,	/* 4 channels */
	ripcord_sample_names
};

static const char *robotbwl_sample_names[] =
{
	"*robotbwl",
	"hit.wav",
	"roll.wav",
	"balldrop.wav",
	"demerit.wav",
	"reward.wav",
	0
};

struct Samplesinterface robotbwl_samples_interface =
{
	5,	/* 5 channels */
	robotbwl_sample_names
};

/* Nodes - Inputs */
#define CIRCUS_MUSIC_BIT	NODE_01
/* Nodes - Sounds */
#define CIRCUS_MUSIC_SND	NODE_10

DISCRETE_SOUND_START(circus)
	/************************************************/
	/* Input register mapping for circus            */
	/************************************************/
	DISCRETE_INPUTX_NOT(CIRCUS_MUSIC_BIT,    20000,  0,      1)

	/************************************************/
	/* Music is just a 1 bit DAC                    */
	/************************************************/
	DISCRETE_CRFILTER(CIRCUS_MUSIC_SND, 1, CIRCUS_MUSIC_BIT, RES_K(50), CAP_U(.1))	/* 50K is just an average value */

	DISCRETE_OUTPUT(CIRCUS_MUSIC_SND, 1)
DISCRETE_SOUND_END

static const discrete_mixer_desc crash_mixer =
{
	DISC_MIXER_IS_RESISTOR,
	{RES_K(22), RES_K(5)},
	{0},
	{CAP_U(.1), CAP_U(.1)},
	0, RES_K(100), 0, CAP_U(.1), 0, 10000
};

static const discrete_555_desc crash_beeper_555m =
{
	DISC_555_TRIGGER_IS_LOGIC | DISC_555_OUT_DC | DISC_555_OUT_SQW,
	5,		// B+ voltage of 555
	DEFAULT_555_VALUES
};

static const discrete_555_desc crash_beeper_555a =
{
	DISC_555_OUT_DC | DISC_555_OUT_SQW,
	5,		// B+ voltage of 555
	DEFAULT_555_VALUES
};

/* Nodes - Inputs */
#define CRASH_MUSIC_BIT		NODE_01
#define CRASH_BEEPER_EN		NODE_02
/* Nodes - Adjusters */
#define CRASH_R63			NODE_10
#define CRASH_R39			NODE_11
/* Nodes - Sounds */
#define CRASH_MUSIC_SND		NODE_20
#define CRASH_BEEPER_SND	NODE_21

DISCRETE_SOUND_START(crash)
	/************************************************/
	/* Input register mapping for crash             */
	/************************************************/
	DISCRETE_INPUT_LOGIC(CRASH_MUSIC_BIT)
	DISCRETE_INPUT_PULSE(CRASH_BEEPER_EN, 1)

	DISCRETE_ADJUSTMENT_TAG(CRASH_R63, 1, 0, 5.0*RES_K(100)/(RES_K(47+100))-0.5, DISC_LINADJ, "R63")
	DISCRETE_ADJUSTMENT_TAG(CRASH_R39, 1, 0, 1, DISC_LINADJ, "R39")

	/************************************************/
	/* Music is just a 1 bit DAC                    */
	/************************************************/
	DISCRETE_MULTADD(CRASH_MUSIC_SND, 1, CRASH_MUSIC_BIT, CRASH_R63, 0.5)

	/************************************************/
	/* Beeper - oneshot gates tone                  */
	/************************************************/
	DISCRETE_555_MSTABLE(NODE_30, 1, CRASH_BEEPER_EN, RES_K(22), CAP_U(.47), &crash_beeper_555m)
	DISCRETE_555_ASTABLE(NODE_31, NODE_30, RES_K(4.7), RES_K(4.7), CAP_U(.1), &crash_beeper_555a)
	DISCRETE_MULTIPLY(CRASH_BEEPER_SND, 1, NODE_31, CRASH_R39)

	/************************************************/
	/* Final mix with gain                          */
	/************************************************/
	DISCRETE_MIXER2(NODE_90, 1, CRASH_MUSIC_SND, CRASH_BEEPER_SND, &crash_mixer)

	DISCRETE_OUTPUT(NODE_90, 1)
DISCRETE_SOUND_END

/* Nodes - Inputs */
#define ROBOTBWL_MUSIC_BIT		NODE_01
/* Nodes - Sounds */
#define ROBOTBWL_MUSIC_SND		NODE_10

DISCRETE_SOUND_START(robotbwl)
	/************************************************/
	/* Input register mapping for robotbwl          */
	/************************************************/
	DISCRETE_INPUTX_LOGIC(ROBOTBWL_MUSIC_BIT,    30000,  0,      0)

	/************************************************/
	/* Music is just a 1 bit DAC                    */
	/************************************************/
	DISCRETE_RCFILTER(NODE_20, 1, ROBOTBWL_MUSIC_BIT, RES_K(10), CAP_U(.47))
	DISCRETE_CRFILTER(ROBOTBWL_MUSIC_SND, 1, NODE_20, RES_K(10) + RES_K(22), CAP_U(.1))

	DISCRETE_OUTPUT(ROBOTBWL_MUSIC_SND, 1)
DISCRETE_SOUND_END


/* This register controls the clown image currently displayed */
/* and also is used to enable the amplifier and trigger the   */
/* discrete circuitry that produces sound effects and music   */

WRITE8_HANDLER( circus_clown_z_w )
{
	clown_z = (data & 0x0f);
	*(memory_region(REGION_CPU1)+0x8000)=data; logerror("Z:%02x\n",data); //DEBUG
	/* Bits 4-6 enable/disable trigger different events */

	switch (circus_game)
	{
		case 1:	/* circus */
		case 4:	/* ripcord */
			switch ((data & 0x70) >> 4)
			{
				case 0 : /* All Off */
					discrete_sound_w(CIRCUS_MUSIC_BIT, 0);
					break;

				case 1 : /* Music */
					discrete_sound_w(CIRCUS_MUSIC_BIT, 1);
					break;

				case 2 : /* Circus = Pop; Rip Cord = Splash */
					sample_start (0, 0, 0);
					break;

				case 3 : /* Normal Video */
					break;

				case 4 : /* Circus = Miss; Rip Cord = Scream */
					sample_start (1, 1, 0);
					break;

				case 5 : /* Invert Video */
					break;

				case 6 : /* Circus = Bounce; Rip Cord = Chute Open */
					sample_start (2, 2, 0);
					break;

				case 7 : /* Circus = not used; Rip Cord = Whistle */
					if GAME_IS_RIPCORD
						sample_start (3, 3, 0);
					break;
			}
			break;

		case 2:	/* robotbwl */
			discrete_sound_w(ROBOTBWL_MUSIC_BIT, data & 0x08);	/* Footsteps */

			if (data & 0x40)	/* Hit */
				sample_start (0, 0, 0);

			if (data & 0x20)	/* Roll */
				sample_start (1, 1, 0);

			if (data & 0x10)	/* Ball Drop */
				sample_start (2, 2, 0);

			if (data & 0x02)	/* Demerit */
				sample_start (3, 3, 0);

			if (data & 0x01)	/* Reward */
				sample_start (4, 4, 0);

			// if (data & 0x04) /* Invert */
			break;

		case 3:	/* crash */
			/* Only the crash can be done with a sample */
			switch ((data & 0x70) >> 4)
			{
				case 0 : /* All Off */
					discrete_sound_w(CRASH_MUSIC_BIT, 0);
					break;

				case 1 : /* Music */
					discrete_sound_w(CRASH_MUSIC_BIT, 1);
					break;

				case 2 : /* Crash */
					sample_start (0, 0, 0);
					break;

				case 3 : /* Normal Video and Beep */
					discrete_sound_w(CRASH_BEEPER_EN, 0);
					break;

				case 4 : /* Skid */
					break;

				case 5 : /* Invert Video and Beep */
					discrete_sound_w(CRASH_BEEPER_EN, 0);
					break;

				case 6 : /* Hi Motor */
					break;

				case 7 : /* Low Motor */
					break;
			}
			break;
	}

	/* Bit 7 enables amplifier (0 = on) */
	sound_global_enable(~data & 0x80);
}