1
/***************************************************************************
3
Galaxian-derived sound hardware
5
****************************************************************************
10
- There is currently no way to exactly reproduce the CD4066 switch control
11
mixing. This is changing impedance of the input resistor for e.g.
12
following filters to >> 10M Ohm. These resistors are static values in
19
- Check more schematics for differences.
21
***************************************************************************/
24
#include "sound/discrete.h"
25
#include "audio/galaxian.h"
27
/*************************************
31
*************************************/
35
#define SOUND_CLOCK (XTAL/6/2) /* 1.536 MHz */
36
#define RNG_RATE (XTAL/3*2) /* RNG clock is XTAL/3*2 see Aaron's note in video/galaxian.c */
39
#define GAL_INP_BG_DAC NODE_10 /* at 9M Q4 to Q7 in schematics */
41
#define GAL_INP_FS1 NODE_20 /* FS1 9L Q0 */
42
#define GAL_INP_FS2 NODE_21 /* FS2 9L Q1 */
43
#define GAL_INP_FS3 NODE_22 /* FS3 9L Q2 */
44
#define GAL_INP_HIT NODE_23 /* HIT 9L Q3 */
45
//#define GAL_9L_Q4 NODE_24
46
#define GAL_INP_FIRE NODE_25 /* FIRE 9L Q5 */
47
#define GAL_INP_VOL1 NODE_26 /* VOL1 9L Q6 */
48
#define GAL_INP_VOL2 NODE_27 /* VOL2 9L Q7 */
50
#define GAL_INP_PITCH NODE_28 /* at 6T in schematics */
54
#define GAL_R15 RES_K(100)
55
#define GAL_R16 RES_K(220)
56
#define GAL_R17 RES_K(470)
57
#define GAL_R18 RES_K(1000)
58
#define GAL_R19 RES_K(330)
60
#define GAL_R20 RES_K(15)
61
#define GAL_R21 RES_K(100)
62
#define GAL_R22 RES_K(100)
63
#define GAL_R23 RES_K(470)
64
#define GAL_R24 RES_K(10)
65
#define GAL_R25 RES_K(100)
66
#define GAL_R26 RES_K(330)
67
#define GAL_R27 RES_K(10)
68
#define GAL_R28 RES_K(100)
69
#define GAL_R29 RES_K(220)
71
#define GAL_R30 RES_K(10)
72
#define GAL_R31 RES_K(47)
73
#define GAL_R32 RES_K(47)
74
#define GAL_R33 RES_K(10)
76
* R34 is given twice on galaxian board and both times as 5.1k. On moon cresta
77
* it is only listed once and given as 15k. This is more in line with recordings
79
#define GAL_R34 RES_K(5.1)
80
#define MCRST_R34 RES_K(15)
82
#define GAL_R35 RES_K(150)
83
#define GAL_R36 RES_K(22)
84
#define GAL_R37 RES_K(470)
85
#define GAL_R38 RES_K(33)
86
#define GAL_R39 RES_K(22)
88
/* The hit sound is too low compared with recordings
89
* There may be an issue with the op-amp band filter
91
#define GAL_R40 (RES_K(2.2)*0.6) /* Volume adjust */
92
#define GAL_R41 RES_K(100)
93
#define GAL_R43 RES_K(2.2)
94
#define GAL_R44 RES_K(10)
95
#define GAL_R45 RES_K(22)
96
#define GAL_R46 RES_K(10)
97
#define GAL_R47 RES_K(2.2)
98
#define GAL_R48 RES_K(2.2)
99
#define GAL_R49 RES_K(10)
101
#define GAL_R50 RES_K(22)
102
#define GAL_R51 RES_K(33)
103
#define GAL_R52 RES_K(15)
105
#define GAL_R91 RES_K(10)
107
#define GAL_C15 CAP_U(1)
108
#define GAL_C17 CAP_U(0.01)
109
#define GAL_C18 CAP_U(0.01)
110
#define GAL_C19 CAP_U(0.01)
112
#define GAL_C20 CAP_U(0.1)
113
#define GAL_C21 CAP_U(2.2)
114
#define GAL_C22 CAP_U(0.01)
115
#define GAL_C23 CAP_U(0.01)
116
#define GAL_C25 CAP_U(1)
117
#define GAL_C26 CAP_U(0.01)
118
#define GAL_C27 CAP_U(0.01)
119
#define GAL_C28 CAP_U(47)
121
#define GAL_C46 CAP_U(0.1)
124
/*************************************
126
* Structures for discrete core
128
*************************************/
131
static const discrete_dac_r1_ladder galaxian_bck_dac =
134
{GAL_R18, GAL_R17, GAL_R16, GAL_R15, 0,0,0,0},
135
4.4, // 5V - diode junction (0.6V)
141
static const discrete_555_cc_desc galaxian_bck_vco =
143
DISC_555_OUT_DC | DISC_555_OUT_CAP,
144
5, // B+ voltage of 555
146
0.7 // Q2 junction voltage
149
static const discrete_555_desc galaxian_555_vco_desc =
151
DISC_555_OUT_ENERGY | DISC_555_OUT_DC,
154
(5.0 - 0.5) // 10k means no real load
157
static const discrete_555_desc galaxian_555_fire_vco_desc =
165
static const discrete_mixer_desc galaxian_bck_mixer_desc =
167
DISC_MIXER_IS_RESISTOR,
168
{GAL_R24, GAL_R27, GAL_R30},
170
{0,0,0,0}, /* no node capacitors */
177
static const discrete_lfsr_desc galaxian_lfsr =
182
4, /* Use Bit 10 (QC of second LS164) as F0 input 0 */
183
16, /* Use Bit 23 (QH of third LS164) as F0 input 1 */
184
DISC_LFSR_XOR_INV_IN1, /* F0 is XOR */
185
DISC_LFSR_IN0, /* F1 is inverted F0*/
186
DISC_LFSR_REPLACE, /* F2 replaces the shifted register contents */
187
0x000001, /* Everything is shifted into the first bit only */
188
DISC_LFSR_FLAG_OUTPUT_F0, /* Output is result of F0 */
192
static const discrete_mixer_desc galaxian_mixerpre_desc =
194
DISC_MIXER_IS_RESISTOR,
195
{GAL_R51, 0, GAL_R50, 0, GAL_R34}, /* A, C, C, D */
196
{0, GAL_INP_VOL1, 0, GAL_INP_VOL2, 0},
204
static const discrete_mixer_desc galaxian_mixer_desc =
206
DISC_MIXER_IS_RESISTOR,
207
{GAL_R34, GAL_R40, GAL_R43}, /* A, C, C, D */
216
/* moon cresta has different mixing */
218
static const discrete_mixer_desc mooncrst_mixer_desc =
220
DISC_MIXER_IS_RESISTOR,
221
{GAL_R51, 0, GAL_R50, 0, MCRST_R34, GAL_R40, GAL_R43}, /* A, C, C, D */
222
{0, GAL_INP_VOL1, 0, GAL_INP_VOL2, 0, 0, 0},
223
{0,0,0,0,0,0,GAL_C26},
230
static const discrete_op_amp_filt_info galaxian_bandpass_desc =
232
GAL_R35, GAL_R36, 0, 0,
235
5.0*GAL_R39/(GAL_R38+GAL_R39),
239
/*************************************
241
* Discrete Sound Blocks
243
*************************************/
246
static DISCRETE_SOUND_START(galaxian)
248
/************************************************/
249
/* Input register mapping for galaxian */
250
/************************************************/
251
DISCRETE_INPUT_DATA(GAL_INP_BG_DAC)
254
DISCRETE_INPUT_LOGIC(GAL_INP_FS1)
255
DISCRETE_INPUT_LOGIC(GAL_INP_FS2)
256
DISCRETE_INPUT_LOGIC(GAL_INP_FS3)
259
DISCRETE_INPUTX_DATA(GAL_INP_HIT, TTL_OUT, 0, 0)
262
DISCRETE_INPUT_LOGIC(GAL_INP_FIRE)
264
/* Turns on / off resistors in mixer */
265
DISCRETE_INPUTX_DATA(GAL_INP_VOL1, GAL_R49, 0, 0)
266
DISCRETE_INPUTX_DATA(GAL_INP_VOL2, GAL_R52, 0, 0)
269
DISCRETE_INPUT_DATA(GAL_INP_PITCH)
271
DISCRETE_TASK_START(0)
273
/************************************************/
275
/************************************************/
277
/* since only a sample of the LFSR is latched @V2 we let the lfsr
278
* run at a lower speed
280
DISCRETE_LFSR_NOISE(NODE_150, 1, 1, RNG_RATE/100, 1.0, 0, 0.5, &galaxian_lfsr)
281
DISCRETE_SQUAREWFIX(NODE_151,1,60*264/2,1.0,50,0.5,0) /* 2V signal */
282
DISCRETE_LOGIC_DFLIPFLOP(NODE_152,1,1,NODE_151,NODE_150)
285
/* Group Background and pitch */
286
DISCRETE_TASK_START(1)
288
/************************************************/
290
/************************************************/
292
DISCRETE_DAC_R1(NODE_100, GAL_INP_BG_DAC, TTL_OUT, &galaxian_bck_dac)
293
DISCRETE_555_CC(NODE_105, 1, NODE_100, GAL_R21, GAL_C15, 0, 0, 0, &galaxian_bck_vco)
294
// Next is mult/add opamp circuit
295
DISCRETE_MULTADD(NODE_110, NODE_105, GAL_R33/RES_3_PARALLEL(GAL_R31,GAL_R32,GAL_R33),
296
-5.0*GAL_R33/GAL_R31)
297
DISCRETE_CLAMP(NODE_111,NODE_110,0.0,5.0)
299
DISCRETE_555_ASTABLE_CV(NODE_115, GAL_INP_FS1, GAL_R22, GAL_R23, GAL_C17, NODE_111, &galaxian_555_vco_desc)
300
DISCRETE_555_ASTABLE_CV(NODE_116, GAL_INP_FS2, GAL_R25, GAL_R26, GAL_C18, NODE_111, &galaxian_555_vco_desc)
301
DISCRETE_555_ASTABLE_CV(NODE_117, GAL_INP_FS3, GAL_R28, GAL_R29, GAL_C19, NODE_111, &galaxian_555_vco_desc)
303
DISCRETE_MIXER3(NODE_120, 1, NODE_115, NODE_116, NODE_117, &galaxian_bck_mixer_desc)
305
/************************************************/
307
/************************************************/
309
/* two cascaded LS164 which are reset to pitch latch value,
310
* thus generating SOUND_CLOCK / (256 - pitch_clock) signal
312
* One possibility to implement this is
313
* DISCRETE_TRANSFORM3(NODE_130, SOUND_CLOCK, 256, GAL_INP_PITCH, "012-/")
314
* DISCRETE_COUNTER(NODE_132, 1, 0, NODE_130, 0, 15, DISC_COUNT_UP, 0, DISC_CLK_IS_FREQ)
315
* but there is a native choice:
317
DISCRETE_NOTE(NODE_132, 1, SOUND_CLOCK, GAL_INP_PITCH, 255, 15, DISC_CLK_IS_FREQ)
319
/* from the 74393 (counter 2 above) only QA, QC, QD are used.
320
* We decode three here and use SUB_NODE(133,x) below to access.
322
DISCRETE_BITS_DECODE(NODE_133, NODE_132, 0, 3, TTL_OUT) /* QA-QD 74393 */
324
/* End of this task */
327
DISCRETE_TASK_START(1)
329
/************************************************/
331
/************************************************/
333
/* Not 100% correct - switching causes high impedance input for node_157
334
* this is not emulated */
335
DISCRETE_RCDISC5(NODE_155, NODE_152, GAL_INP_HIT, (GAL_R35 + GAL_R36), GAL_C21)
336
DISCRETE_OP_AMP_FILTER(NODE_157, 1, NODE_155, 0, DISC_OP_AMP_FILTER_IS_BAND_PASS_1M, &galaxian_bandpass_desc)
339
DISCRETE_TASK_START(1)
340
/************************************************/
342
/************************************************/
344
DISCRETE_LOGIC_INVERT(NODE_170, GAL_INP_FIRE)
345
DISCRETE_MULTIPLY(NODE_171, TTL_OUT, GAL_INP_FIRE)
346
DISCRETE_MULTIPLY(NODE_172, TTL_OUT, NODE_170) // inverted
347
DISCRETE_RCFILTER(NODE_173, NODE_172, GAL_R47, GAL_C28)
348
/* Mix noise and 163 */
349
DISCRETE_TRANSFORM5(NODE_177, NODE_152, TTL_OUT, 1.0/GAL_R46, NODE_173, 1.0/GAL_R48,
351
//DISCRETE_MULTIPLY(NODE_174, 1, TTL_OUT, NODE_152)
352
//DISCRETE_MULTIPLY(NODE_175, 1, 1.0/GAL_R46, NODE_174)
353
//DISCRETE_MULTIPLY(NODE_176, 1, 1.0/GAL_R48, NODE_173)
354
//DISCRETE_ADDER2(NODE_177, 1, NODE_175, NODE_176)
355
DISCRETE_MULTIPLY(NODE_178, RES_2_PARALLEL(GAL_R46, GAL_R48), NODE_177)
357
DISCRETE_555_ASTABLE_CV(NODE_181, 1, GAL_R44, GAL_R45, GAL_C27, NODE_178, &galaxian_555_fire_vco_desc)
359
/* 555 toggles discharge on rc discharge module */
360
DISCRETE_RCDISC5(NODE_182, NODE_181, NODE_171, (GAL_R41), GAL_C25)
365
/************************************************/
367
/************************************************/
369
DISCRETE_TASK_START(2)
370
DISCRETE_MIXER5(NODE_279, 1, NODE_133_00, NODE_133_02, NODE_133_02, NODE_133_03, NODE_120, &galaxian_mixerpre_desc)
371
DISCRETE_MIXER3(NODE_280, 1, NODE_279, NODE_157, NODE_182, &galaxian_mixer_desc)
372
DISCRETE_OUTPUT(NODE_280, 32767.0/5.0*5)
378
static DISCRETE_SOUND_START(mooncrst)
379
DISCRETE_IMPORT(galaxian)
381
/************************************************/
382
/* Moon Cresta mixing stage */
383
/************************************************/
384
DISCRETE_DELETE(NODE_279, NODE_279)
386
DISCRETE_MIXER7(NODE_280, 1, NODE_133_00, NODE_133_02, NODE_133_02,NODE_133_03, NODE_120, NODE_157, NODE_182, &mooncrst_mixer_desc)
389
/*************************************
393
*************************************/
395
static UINT8 lfo_val;
397
static SOUND_START(galaxian)
402
/*************************************
406
*************************************/
409
WRITE8_DEVICE_HANDLER( galaxian_pitch_w )
411
discrete_sound_w(device, GAL_INP_PITCH, data );
414
WRITE8_DEVICE_HANDLER( galaxian_lfo_freq_w )
416
UINT8 lfo_val_new = (lfo_val & ~(1<<offset)) | ((data & 0x01) << offset);
418
if (lfo_val != lfo_val_new)
420
lfo_val = lfo_val_new;
421
discrete_sound_w(device, GAL_INP_BG_DAC, lfo_val);
425
WRITE8_DEVICE_HANDLER( galaxian_background_enable_w )
427
discrete_sound_w(device, NODE_RELATIVE(GAL_INP_FS1, offset), data & 0x01);
430
WRITE8_DEVICE_HANDLER( galaxian_noise_enable_w )
432
discrete_sound_w(device, GAL_INP_HIT, data & 0x01);
435
WRITE8_DEVICE_HANDLER( galaxian_vol_w )
437
discrete_sound_w(device, NODE_RELATIVE(GAL_INP_VOL1,offset), data & 0x01);
440
/* FIXME: rename to fire to be consistent */
441
WRITE8_DEVICE_HANDLER( galaxian_shoot_enable_w )
443
discrete_sound_w(device, GAL_INP_FIRE, data & 0x01);
446
/* FIXME: May be replaced by one call! */
447
WRITE8_DEVICE_HANDLER( galaxian_sound_w )
452
case 0: /* FS1 (controls 555 timer at 8R) */
453
case 1: /* FS2 (controls 555 timer at 8S) */
454
case 2: /* FS3 (controls 555 timer at 8T) */
455
galaxian_background_enable_w(device, offset, data);
459
galaxian_noise_enable_w(device, 0, data);
466
galaxian_shoot_enable_w(device, 0, data);
471
galaxian_vol_w(device, offset & 1, data);
476
/*************************************
480
*************************************/
482
MACHINE_CONFIG_FRAGMENT( galaxian_audio )
484
MCFG_SOUND_START(galaxian)
486
MCFG_SOUND_ADD(GAL_AUDIO, DISCRETE, 0)
487
MCFG_SOUND_CONFIG_DISCRETE(galaxian)
489
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
492
MACHINE_CONFIG_FRAGMENT( mooncrst_audio )
494
MCFG_SOUND_START(galaxian)
496
MCFG_SOUND_ADD(GAL_AUDIO, DISCRETE, 0)
497
MCFG_SOUND_CONFIG_DISCRETE(mooncrst)
499
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)