~ubuntu-branches/ubuntu/raring/mame/raring-proposed

« back to all changes in this revision

Viewing changes to mess/src/mame/audio/skyraid.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/************************************************************************
2
 
 * skyraid Sound System Analog emulation
3
 
 * Sept 2009, Derrick Renaud
4
 
 ************************************************************************/
5
 
 
6
 
#include "emu.h"
7
 
#include "includes/skyraid.h"
8
 
 
9
 
 
10
 
/* Discrete Sound Input Nodes */
11
 
#define SKYRAID_PLANE_SWEEP_EN          NODE_01
12
 
#define SKYRAID_MISSILE_EN                      NODE_02
13
 
#define SKYRAID_EXPLOSION_EN            NODE_03
14
 
#define SKYRAID_PLANE_ON_EN                     NODE_04
15
 
#define SKYRAID_PLANE_ON__IC_E8         SKYRAID_PLANE_ON_EN
16
 
#define SKYRAID_ATTRACT_EN                      NODE_05
17
 
 
18
 
/* Discrete Sound Output Nodes */
19
 
#define SKYRAID_NOISE                           NODE_10
20
 
#define SKYRAID_EXPLOSION_SND           NODE_11
21
 
#define SKYRAID_JET_A_SND                       NODE_12
22
 
#define SKYRAID_JET_B_SND                       NODE_13
23
 
#define SKYRAID_MSL_A_SND                       NODE_14
24
 
#define SKYRAID_MSL_B_SND                       NODE_15
25
 
#define SKYRAID_PLANE_SND                       NODE_16
26
 
 
27
 
/* Parts List - Resistors */
28
 
#define SKYRAID_R12             RES_K(1)
29
 
#define SKYRAID_R13             RES_K(10)
30
 
#define SKYRAID_R14             RES_K(100)
31
 
#define SKYRAID_R16             RES_K(10)
32
 
#define SKYRAID_R18             RES_K(10)
33
 
#define SKYRAID_R19             RES_K(10)
34
 
#define SKYRAID_R20             RES_K(47)
35
 
#define SKYRAID_R24             RES_M(10)
36
 
#define SKYRAID_R25             RES_M(3.9)
37
 
#define SKYRAID_R27             RES_M(1.5)
38
 
#define SKYRAID_R28             RES_M(1.5)
39
 
#define SKYRAID_R29             RES_M(4.7)
40
 
#define SKYRAID_R30             RES_M(1)
41
 
#define SKYRAID_R31             RES_M(1)
42
 
#define SKYRAID_R32             RES_M(4.7)
43
 
#define SKYRAID_R84             RES_K(22)
44
 
#define SKYRAID_R85             RES_K(100)
45
 
#define SKYRAID_R86             820
46
 
#define SKYRAID_R110    RES_K(330)
47
 
#define SKYRAID_R118    RES_K(470)
48
 
#define SKYRAID_R119    RES_K(10)
49
 
#define SKYRAID_R120    RES_K(220)
50
 
#define SKYRAID_R121    RES_K(1)
51
 
#define SKYRAID_R122    RES_K(150)
52
 
 
53
 
/* Parts List - Capacitors */
54
 
#define SKYRAID_C44             CAP_U(4.7)
55
 
#define SKYRAID_C45             CAP_U(.0047)
56
 
#define SKYRAID_C46             CAP_U(.001)
57
 
#define SKYRAID_C48             CAP_U(.0047)
58
 
#define SKYRAID_C49             CAP_U(.1)
59
 
#define SKYRAID_C50             CAP_U(.001)
60
 
#define SKYRAID_C51             CAP_U(.01)
61
 
#define SKYRAID_C68             CAP_U(10)
62
 
#define SKYRAID_C85             CAP_U(.068)
63
 
#define SKYRAID_C86             CAP_U(.1)
64
 
#define SKYRAID_C93             CAP_U(.1)
65
 
 
66
 
 
67
 
static const discrete_lfsr_desc skyraid_lfsr =
68
 
{
69
 
        DISC_CLK_IS_FREQ,
70
 
        16,                                     /* Bit Length */
71
 
        0,                                      /* Reset Value */
72
 
        0,                                      /* Use Bit 0 as XOR input 0 */
73
 
        14,                                     /* Use Bit 14 as XOR input 1 */
74
 
        DISC_LFSR_XNOR,         /* Feedback stage1 is XNOR */
75
 
        DISC_LFSR_OR,           /* Feedback stage2 is just stage 1 output OR with external feed */
76
 
        DISC_LFSR_REPLACE,      /* Feedback stage3 replaces the shifted register contents */
77
 
        0x000001,                       /* Everything is shifted into the first bit only */
78
 
        DISC_LFSR_FLAG_RESET_TYPE_H,    /* Output is not inverted */
79
 
        15                                      /* Output bit */
80
 
};
81
 
 
82
 
static const discrete_op_amp_filt_info skyraid_explosion_filter =
83
 
{
84
 
        SKYRAID_R85, 0, SKYRAID_R86, 0, SKYRAID_R110,   /* r1, r2, r3, r4, rF*/
85
 
        SKYRAID_C85, SKYRAID_C86, 0,    /* c1, c2, c3 */
86
 
        0, 12, -5,      /* vRef, vP, vN */
87
 
};
88
 
 
89
 
static const discrete_dac_r1_ladder skyraid_plane_dac =
90
 
{
91
 
        2, {SKYRAID_R28, SKYRAID_R27},
92
 
        0, 0, 0, 0                              /* no vBias, rBias, rGnd, cFilter */
93
 
};
94
 
 
95
 
static const discrete_mixer_desc skyraid_mixer =
96
 
{
97
 
        DISC_MIXER_IS_RESISTOR,
98
 
        {SKYRAID_R120, SKYRAID_R32, SKYRAID_R29, SKYRAID_R30, SKYRAID_R31, RES_2_PARALLEL(SKYRAID_R28, SKYRAID_R27)},
99
 
        {0, 0, 0, 0, 0, SKYRAID_PLANE_ON__IC_E8},       /* r_nodes */
100
 
        {0}, 0, 0, 0, 0, 0, 1           /* no c, rI, rF, cF, cAmp, vRef, gain */
101
 
};
102
 
 
103
 
 
104
 
/************************************************************************
105
 
 *
106
 
 * Custom skyraid missle charge
107
 
 *
108
 
 * input[0]    - In1 (Logic)
109
 
 * input[1]    - R1
110
 
 * input[2]    - R2
111
 
 * input[3]    - R3
112
 
 * input[4]    - C
113
 
 *
114
 
 *              12V            5V
115
 
 *               v              v
116
 
 *               |              |
117
 
 *               Z             ---
118
 
 *               Z R1           ^   1N914
119
 
 *               Z             / \  Diode
120
 
 *               |            -----
121
 
 *               |              |
122
 
 *               +--------------+
123
 
 *               |              |
124
 
 *              ---             Z
125
 
 *              --- C           Z R2
126
 
 *               |              Z
127
 
 *               |              |
128
 
 *               +--------------+----> Node Output
129
 
 *               |
130
 
 *               Z
131
 
 *               Z R3
132
 
 *         O.C.  Z
133
 
 *          |\   |
134
 
 *   In1 >--| o--+
135
 
 *          |/
136
 
 *
137
 
 ************************************************************************/
138
 
#define SKYRAID_MISSLE_CUSTOM_IN1               DISCRETE_INPUT(0)
139
 
#define SKYRAID_MISSLE_CUSTOM_R1                DISCRETE_INPUT(1)
140
 
#define SKYRAID_MISSLE_CUSTOM_R2                DISCRETE_INPUT(2)
141
 
#define SKYRAID_MISSLE_CUSTOM_R3                DISCRETE_INPUT(3)
142
 
#define SKYRAID_MISSLE_CUSTOM_C                 DISCRETE_INPUT(4)
143
 
 
144
 
DISCRETE_CLASS_STEP_RESET(skyraid_missle_custom_charge, 2,
145
 
                double m_v_charge[2];
146
 
                double m_v_cap;
147
 
                double m_exp[2];
148
 
);
149
 
 
150
 
/* the high charge is clamped by the diode to 0.7V above the 5V line */
151
 
#define SKYRAID_MISSLE_CHARGE_PLUS      (5.0 + 0.7)
152
 
 
153
 
DISCRETE_STEP( skyraid_missle_custom_charge )
154
 
{
155
 
        int in_1 = (SKYRAID_MISSLE_CUSTOM_IN1 == 0) ? 0 : 1;
156
 
 
157
 
        /* charge/discharge cap */
158
 
        m_v_cap += (m_v_charge[in_1] - m_v_cap) * m_exp[in_1];
159
 
 
160
 
        set_output(0,  SKYRAID_MISSLE_CHARGE_PLUS - m_v_cap);
161
 
}
162
 
 
163
 
DISCRETE_RESET( skyraid_missle_custom_charge )
164
 
{
165
 
        /* everything is based on the input to the O.C. inverter */
166
 
 
167
 
        /* the charging voltage across the cap */
168
 
        m_v_charge[0] = 0;
169
 
        m_v_charge[1] = SKYRAID_MISSLE_CHARGE_PLUS * RES_VOLTAGE_DIVIDER(SKYRAID_MISSLE_CUSTOM_R1 + SKYRAID_MISSLE_CUSTOM_R2, SKYRAID_MISSLE_CUSTOM_R3);
170
 
        m_v_charge[1] = SKYRAID_MISSLE_CHARGE_PLUS - m_v_charge[1];
171
 
        m_v_cap = 0;
172
 
 
173
 
        /* precalculate charging exponents */
174
 
        /* discharge cap */
175
 
        m_exp[0] = RC_CHARGE_EXP(SKYRAID_MISSLE_CUSTOM_R2 * SKYRAID_MISSLE_CUSTOM_C);
176
 
        /* charge cap */
177
 
        m_exp[1] = RC_CHARGE_EXP(RES_2_PARALLEL(SKYRAID_MISSLE_CUSTOM_R1 + SKYRAID_MISSLE_CUSTOM_R2, SKYRAID_MISSLE_CUSTOM_R3) * SKYRAID_MISSLE_CUSTOM_C);
178
 
 
179
 
        /* starts at full voltage until cap starts charging */
180
 
        set_output(0,  SKYRAID_MISSLE_CHARGE_PLUS);
181
 
}
182
 
 
183
 
 
184
 
 
185
 
DISCRETE_SOUND_START( skyraid )
186
 
        /************************************************
187
 
     * Input register mapping
188
 
     ************************************************/
189
 
        /* convert the PLANE_SWEEP line to voltage*/
190
 
        DISCRETE_INPUTX_LOGIC(SKYRAID_PLANE_SWEEP_EN, DEFAULT_TTL_V_LOGIC_1 * RES_VOLTAGE_DIVIDER(SKYRAID_R25, SKYRAID_R24), 0, 0)
191
 
        DISCRETE_INPUT_LOGIC(SKYRAID_MISSILE_EN)
192
 
        DISCRETE_INPUT_LOGIC(SKYRAID_EXPLOSION_EN)
193
 
        /* convert PLANE_ON into 4066 Ron value of 270 ohms @ 5V */
194
 
        DISCRETE_INPUTX_LOGIC(SKYRAID_PLANE_ON__IC_E8, 270, 0, 0)
195
 
        DISCRETE_INPUT_LOGIC(SKYRAID_ATTRACT_EN)
196
 
 
197
 
        /************************************************
198
 
     * Noise Generator, Explosion sound
199
 
     ************************************************/
200
 
        /* Note: the noise reset is not emulated 100% accurate */
201
 
        /* According to the schematics, Attract only clears the lower 8 bits. */
202
 
        /* I may modify the noise module in the future to properly emulate this, */
203
 
        /* but you will never hear the difference. */
204
 
        /* It only wrong for 8 cycles of the 555 while no sound is being generated. */
205
 
        DISCRETE_LFSR_NOISE(SKYRAID_NOISE,                      /* IC F7, pin 13 */
206
 
                1,                                                                              /* ENAB */
207
 
                SKYRAID_ATTRACT_EN,                                             /* RESET */
208
 
                1.49 / ((SKYRAID_R20 + 2 * SKYRAID_R19) * SKYRAID_C51),         /* CLK - 555 astable source */
209
 
                1, 0, 0.5, &skyraid_lfsr)                               /* AMPL, FEED, BIAS */
210
 
 
211
 
        DISCRETE_LOGIC_NOR(NODE_20, SKYRAID_EXPLOSION_EN, SKYRAID_NOISE)
212
 
        DISCRETE_RC_CIRCUIT_1(NODE_21,
213
 
                SKYRAID_EXPLOSION_EN, NODE_20,                  /* INP0, INP1 */
214
 
                RES_2_PARALLEL(SKYRAID_R84, SKYRAID_R85 + SKYRAID_R86), SKYRAID_C68)
215
 
        DISCRETE_OP_AMP_FILTER(NODE_22,
216
 
                1,                                                                              /* ENAB */
217
 
                NODE_21, 0,                                                             /* INP0, INP1 */
218
 
                DISC_OP_AMP_FILTER_IS_BAND_PASS_1M, &skyraid_explosion_filter)  /* TYPE,INFO */
219
 
        /* IC E10, pin 14 gain and clipping */
220
 
        DISCRETE_GAIN(NODE_23, NODE_22, SKYRAID_R119 / SKYRAID_R121 + 1)
221
 
        DISCRETE_CLAMP(SKYRAID_EXPLOSION_SND, NODE_23, -5, 12.0 - 1.5)
222
 
 
223
 
        /************************************************
224
 
     * Jet, Plane sound
225
 
     ************************************************/
226
 
        DISCRETE_RCFILTER(NODE_30,                              /* IC J6, pin 5 */
227
 
                SKYRAID_PLANE_SWEEP_EN,                         /* IN0 */
228
 
                RES_2_PARALLEL(SKYRAID_R25, SKYRAID_R24), SKYRAID_C49)
229
 
        DISCRETE_566(NODE_31,                                   /* IC J6, pin 3 */
230
 
                NODE_30,                                                        /* VMOD */
231
 
                SKYRAID_R18, SKYRAID_C48,
232
 
                5, -5, 5,                                                       /* VPOS,VNEG,VCHARGE */
233
 
                DISC_566_OUT_COUNT_R)
234
 
        DISCRETE_LOGIC_SHIFT(NODE_32,                   /* IC H7, J7 output */
235
 
                SKYRAID_NOISE,                                          /* IC H7, J7 pins 1 & 2 */
236
 
                1, NODE_31, 16,                                         /* RESET, CLK, SIZE */
237
 
                DISC_LOGIC_SHIFT__RESET_L | DISC_LOGIC_SHIFT__LEFT | DISC_CLK_BY_COUNT)
238
 
        /* move bits together for ease of use */
239
 
        DISCRETE_TRANSFORM4(NODE_33, NODE_32, 1, 1 << 14, 2, "01&02/3&|")
240
 
        DISCRETE_DAC_R1(SKYRAID_PLANE_SND,
241
 
                NODE_33,                                                        /* DATA */
242
 
                DEFAULT_TTL_V_LOGIC_1, &skyraid_plane_dac)
243
 
        DISCRETE_BIT_DECODE(SKYRAID_JET_A_SND, NODE_32, 0, DEFAULT_TTL_V_LOGIC_1)       /* IC H7, pin 3 */
244
 
        DISCRETE_BIT_DECODE(SKYRAID_JET_B_SND, NODE_32, 15, DEFAULT_TTL_V_LOGIC_1)      /* IC J7, pin 13 */
245
 
 
246
 
        /************************************************
247
 
     * Missle sound
248
 
     ************************************************/
249
 
        DISCRETE_CUSTOM5(NODE_40, skyraid_missle_custom_charge, SKYRAID_MISSILE_EN, SKYRAID_R12, SKYRAID_R14, SKYRAID_R13, SKYRAID_C44, NULL)
250
 
        DISCRETE_566(NODE_41,                                   /* IC K6, pin 3 */
251
 
                NODE_40,                                                        /* VMOD */
252
 
                SKYRAID_R16, SKYRAID_C45,
253
 
                5, -5, SKYRAID_MISSLE_CHARGE_PLUS,      /* VPOS,VNEG,VCHARGE */
254
 
                DISC_566_OUT_COUNT_R)
255
 
        DISCRETE_LOGIC_SHIFT(NODE_42,                   /* IC K7, L7 output */
256
 
                SKYRAID_NOISE,                                          /* IC K7, L7 pins 1 & 2 */
257
 
                1, NODE_41, 16,                                         /* RESET, CLK, SIZE */
258
 
                DISC_LOGIC_SHIFT__RESET_L | DISC_LOGIC_SHIFT__LEFT | DISC_CLK_BY_COUNT)
259
 
        DISCRETE_BIT_DECODE(SKYRAID_MSL_A_SND, NODE_42, 0, DEFAULT_TTL_V_LOGIC_1)       /* IC K7, pin 3 */
260
 
        DISCRETE_BIT_DECODE(SKYRAID_MSL_B_SND, NODE_42, 15, DEFAULT_TTL_V_LOGIC_1)      /* IC L7, pin 13 */
261
 
 
262
 
        /************************************************
263
 
     * Final Mix
264
 
     ************************************************/
265
 
        DISCRETE_LOGIC_INVERT(NODE_91, SKYRAID_ATTRACT_EN)
266
 
        DISCRETE_MIXER6(NODE_92,
267
 
                NODE_91,                                /* ENAB */
268
 
                SKYRAID_EXPLOSION_SND,
269
 
                SKYRAID_JET_A_SND,
270
 
                SKYRAID_JET_B_SND,
271
 
                SKYRAID_MSL_A_SND,
272
 
                SKYRAID_MSL_B_SND,
273
 
                SKYRAID_PLANE_SND,
274
 
                &skyraid_mixer)
275
 
        DISCRETE_CRFILTER(NODE_93,
276
 
                NODE_92,                                /* IN0 */
277
 
                SKYRAID_R122 + RES_6_PARALLEL(SKYRAID_R120, SKYRAID_R32, SKYRAID_R29, SKYRAID_R30, SKYRAID_R31, RES_2_PARALLEL(SKYRAID_R27, SKYRAID_R28)),
278
 
                SKYRAID_C93)
279
 
        /* IC E10, pin 1 gain and clipping */
280
 
        DISCRETE_GAIN(NODE_94, NODE_93, - SKYRAID_R118 / (SKYRAID_R122 + RES_5_PARALLEL(SKYRAID_R120, SKYRAID_R32, SKYRAID_R29, SKYRAID_R30, SKYRAID_R31)))
281
 
        DISCRETE_CLAMP(NODE_95, NODE_94, -5, 12.0 - 1.5)
282
 
        DISCRETE_OUTPUT(NODE_95, 32700.0/8)
283
 
DISCRETE_SOUND_END
284
 
 
285
 
 
286
 
WRITE8_DEVICE_HANDLER( skyraid_sound_w )
287
 
{
288
 
        /* BIT0 => PLANE SWEEP */
289
 
        /* BIT1 => MISSILE     */
290
 
        /* BIT2 => EXPLOSION   */
291
 
        /* BIT3 => START LAMP  */
292
 
        /* BIT4 => PLANE ON    */
293
 
        /* BIT5 => ATTRACT     */
294
 
 
295
 
        discrete_sound_w(device, SKYRAID_PLANE_SWEEP_EN, data & 0x01);
296
 
        discrete_sound_w(device, SKYRAID_MISSILE_EN, data & 0x02);
297
 
        discrete_sound_w(device, SKYRAID_EXPLOSION_EN, data & 0x04);
298
 
        set_led_status(device->machine(), 0, !(data & 0x08));
299
 
        discrete_sound_w(device, SKYRAID_PLANE_ON_EN, data & 0x10);
300
 
        discrete_sound_w(device, SKYRAID_ATTRACT_EN, data & 0x20);
301
 
}