trunk/src/mame/audio/polepos.c
| r21254 | r21255 | |
| 3 | 3 | Sound handler |
| 4 | 4 | ****************************************************************************/ |
| 5 | 5 | #include "emu.h" |
| 6 | | #include "sound/filter.h" |
| 7 | 6 | #include "machine/rescap.h" |
| 8 | 7 | #include "namco52.h" |
| 9 | 8 | #include "namco54.h" |
| r21254 | r21255 | |
| 14 | 13 | #define POLEPOS_R166 1000.0 |
| 15 | 14 | #define POLEPOS_R167 2200.0 |
| 16 | 15 | #define POLEPOS_R168 4700.0 |
| 16 | |
| 17 | 17 | /* resistor values when shorted by 4066 running at 5V */ |
| 18 | 18 | #define POLEPOS_R166_SHUNT 1.0/(1.0/POLEPOS_R166 + 1.0/250) |
| 19 | 19 | #define POLEPOS_R167_SHUNT 1.0/(1.0/POLEPOS_R166 + 1.0/250) |
| 20 | 20 | #define POLEPOS_R168_SHUNT 1.0/(1.0/POLEPOS_R166 + 1.0/250) |
| 21 | 21 | |
| 22 | | struct polepos_sound_state |
| 23 | | { |
| 24 | | UINT32 m_current_position; |
| 25 | | int m_sample_msb; |
| 26 | | int m_sample_lsb; |
| 27 | | int m_sample_enable; |
| 28 | | sound_stream *m_stream; |
| 29 | | filter2_context m_filter_engine[3]; |
| 30 | | }; |
| 31 | | |
| 32 | | |
| 33 | 22 | static const double volume_table[8] = |
| 34 | 23 | { |
| 35 | 24 | (POLEPOS_R168_SHUNT + POLEPOS_R167_SHUNT + POLEPOS_R166_SHUNT + 2200) / 10000, |
| r21254 | r21255 | |
| 45 | 34 | static const double r_filt_out[3] = {RES_K(4.7), RES_K(7.5), RES_K(10)}; |
| 46 | 35 | static const double r_filt_total = 1.0 / (1.0/RES_K(4.7) + 1.0/RES_K(7.5) + 1.0/RES_K(10)); |
| 47 | 36 | |
| 48 | | INLINE polepos_sound_state *get_safe_token( device_t *device ) |
| 37 | |
| 38 | |
| 39 | |
| 40 | // device type definition |
| 41 | const device_type POLEPOS = &device_creator<polepos_sound_device>; |
| 42 | |
| 43 | |
| 44 | //************************************************************************** |
| 45 | // LIVE DEVICE |
| 46 | //************************************************************************** |
| 47 | |
| 48 | //------------------------------------------------- |
| 49 | // polepos_sound_device - constructor |
| 50 | //------------------------------------------------- |
| 51 | |
| 52 | polepos_sound_device::polepos_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 53 | : device_t(mconfig, POLEPOS, "Pole Position Custom", tag, owner, clock), |
| 54 | device_sound_interface(mconfig, *this), |
| 55 | m_current_position(0), |
| 56 | m_sample_msb(0), |
| 57 | m_sample_lsb(0), |
| 58 | m_sample_enable(0), |
| 59 | m_stream(NULL) |
| 49 | 60 | { |
| 50 | | assert(device != NULL); |
| 51 | | assert(device->type() == POLEPOS); |
| 61 | } |
| 52 | 62 | |
| 53 | | return (polepos_sound_state *)downcast<polepos_sound_device *>(device)->token(); |
| 63 | |
| 64 | //------------------------------------------------- |
| 65 | // device_start - device-specific startup |
| 66 | //------------------------------------------------- |
| 67 | |
| 68 | void polepos_sound_device::device_start() |
| 69 | { |
| 70 | m_stream = stream_alloc(0, 1, OUTPUT_RATE); |
| 71 | m_sample_msb = m_sample_lsb = 0; |
| 72 | m_sample_enable = 0; |
| 73 | |
| 74 | /* setup the filters */ |
| 75 | filter_opamp_m_bandpass_setup(this, RES_K(220), RES_K(33), RES_K(390), CAP_U(.01), CAP_U(.01), |
| 76 | &m_filter_engine[0]); |
| 77 | filter_opamp_m_bandpass_setup(this, RES_K(150), RES_K(22), RES_K(330), CAP_U(.0047), CAP_U(.0047), |
| 78 | &m_filter_engine[1]); |
| 79 | /* Filter 3 is a little different. Because of the input capacitor, it is |
| 80 | * a high pass filter. */ |
| 81 | filter2_setup(this, FILTER_HIGHPASS, 950, Q_TO_DAMP(.707), 1, &m_filter_engine[2]); |
| 54 | 82 | } |
| 55 | 83 | |
| 56 | | /************************************/ |
| 57 | | /* Stream updater */ |
| 58 | | /************************************/ |
| 59 | | static STREAM_UPDATE( engine_sound_update ) |
| 84 | |
| 85 | //------------------------------------------------- |
| 86 | // device_reset - device-specific reset |
| 87 | //------------------------------------------------- |
| 88 | |
| 89 | void polepos_sound_device::device_reset() |
| 60 | 90 | { |
| 61 | | polepos_sound_state *state = get_safe_token(device); |
| 91 | int loop; |
| 92 | for (loop = 0; loop < 3; loop++) |
| 93 | filter2_reset(&m_filter_engine[loop]); |
| 94 | } |
| 95 | |
| 96 | |
| 97 | //------------------------------------------------- |
| 98 | // sound_stream_update - handle a stream update |
| 99 | //------------------------------------------------- |
| 100 | |
| 101 | void polepos_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 102 | { |
| 62 | 103 | UINT32 step, clock, slot; |
| 63 | 104 | UINT8 *base; |
| 64 | 105 | double volume, i_total; |
| r21254 | r21255 | |
| 66 | 107 | int loop; |
| 67 | 108 | |
| 68 | 109 | /* if we're not enabled, just fill with 0 */ |
| 69 | | if (!state->m_sample_enable) |
| 110 | if (!m_sample_enable) |
| 70 | 111 | { |
| 71 | 112 | memset(buffer, 0, samples * sizeof(*buffer)); |
| 72 | 113 | return; |
| 73 | 114 | } |
| 74 | 115 | |
| 75 | 116 | /* determine the effective clock rate */ |
| 76 | | clock = (device->machine().device("maincpu")->unscaled_clock() / 16) * ((state->m_sample_msb + 1) * 64 + state->m_sample_lsb + 1) / (64*64); |
| 117 | clock = (machine().device("maincpu")->unscaled_clock() / 16) * ((m_sample_msb + 1) * 64 + m_sample_lsb + 1) / (64*64); |
| 77 | 118 | step = (clock << 12) / OUTPUT_RATE; |
| 78 | 119 | |
| 79 | 120 | /* determine the volume */ |
| 80 | | slot = (state->m_sample_msb >> 3) & 7; |
| 121 | slot = (m_sample_msb >> 3) & 7; |
| 81 | 122 | volume = volume_table[slot]; |
| 82 | | base = &device->machine().root_device().memregion("engine")->base()[slot * 0x800]; |
| 123 | base = &machine().root_device().memregion("engine")->base()[slot * 0x800]; |
| 83 | 124 | |
| 84 | 125 | /* fill in the sample */ |
| 85 | 126 | while (samples--) |
| 86 | 127 | { |
| 87 | | state->m_filter_engine[0].x0 = (3.4 / 255 * base[(state->m_current_position >> 12) & 0x7ff] - 2) * volume; |
| 88 | | state->m_filter_engine[1].x0 = state->m_filter_engine[0].x0; |
| 89 | | state->m_filter_engine[2].x0 = state->m_filter_engine[0].x0; |
| 128 | m_filter_engine[0].x0 = (3.4 / 255 * base[(m_current_position >> 12) & 0x7ff] - 2) * volume; |
| 129 | m_filter_engine[1].x0 = m_filter_engine[0].x0; |
| 130 | m_filter_engine[2].x0 = m_filter_engine[0].x0; |
| 90 | 131 | |
| 91 | 132 | i_total = 0; |
| 92 | 133 | for (loop = 0; loop < 3; loop++) |
| 93 | 134 | { |
| 94 | | filter2_step(&state->m_filter_engine[loop]); |
| 135 | filter2_step(&m_filter_engine[loop]); |
| 95 | 136 | /* The op-amp powered @ 5V will clip to 0V & 3.5V. |
| 96 | 137 | * Adjusted to vRef of 2V, we will clip as follows: */ |
| 97 | | if (state->m_filter_engine[loop].y0 > 1.5) state->m_filter_engine[loop].y0 = 1.5; |
| 98 | | if (state->m_filter_engine[loop].y0 < -2) state->m_filter_engine[loop].y0 = -2; |
| 138 | if (m_filter_engine[loop].y0 > 1.5) m_filter_engine[loop].y0 = 1.5; |
| 139 | if (m_filter_engine[loop].y0 < -2) m_filter_engine[loop].y0 = -2; |
| 99 | 140 | |
| 100 | | i_total += state->m_filter_engine[loop].y0 / r_filt_out[loop]; |
| 141 | i_total += m_filter_engine[loop].y0 / r_filt_out[loop]; |
| 101 | 142 | } |
| 102 | 143 | i_total *= r_filt_total * 32000/2; /* now contains voltage adjusted by final gain */ |
| 103 | 144 | |
| 104 | 145 | *buffer++ = (int)i_total; |
| 105 | | state->m_current_position += step; |
| 146 | m_current_position += step; |
| 106 | 147 | } |
| 107 | 148 | } |
| 108 | 149 | |
| 109 | | /************************************/ |
| 110 | | /* Sound handler start */ |
| 111 | | /************************************/ |
| 112 | | static DEVICE_START( polepos_sound ) |
| 113 | | { |
| 114 | | polepos_sound_state *state = get_safe_token(device); |
| 115 | | state->m_stream = device->machine().sound().stream_alloc(*device, 0, 1, OUTPUT_RATE, NULL, engine_sound_update); |
| 116 | | state->m_sample_msb = state->m_sample_lsb = 0; |
| 117 | | state->m_sample_enable = 0; |
| 118 | 150 | |
| 119 | | /* setup the filters */ |
| 120 | | filter_opamp_m_bandpass_setup(device, RES_K(220), RES_K(33), RES_K(390), CAP_U(.01), CAP_U(.01), |
| 121 | | &state->m_filter_engine[0]); |
| 122 | | filter_opamp_m_bandpass_setup(device, RES_K(150), RES_K(22), RES_K(330), CAP_U(.0047), CAP_U(.0047), |
| 123 | | &state->m_filter_engine[1]); |
| 124 | | /* Filter 3 is a little different. Because of the input capacitor, it is |
| 125 | | * a high pass filter. */ |
| 126 | | filter2_setup(device, FILTER_HIGHPASS, 950, Q_TO_DAMP(.707), 1, |
| 127 | | &state->m_filter_engine[2]); |
| 128 | | } |
| 129 | | |
| 130 | 151 | /************************************/ |
| 131 | | /* Sound handler reset */ |
| 132 | | /************************************/ |
| 133 | | static DEVICE_RESET( polepos_sound ) |
| 134 | | { |
| 135 | | polepos_sound_state *state = get_safe_token(device); |
| 136 | | int loop; |
| 137 | | for (loop = 0; loop < 3; loop++) |
| 138 | | filter2_reset(&state->m_filter_engine[loop]); |
| 139 | | } |
| 140 | | |
| 141 | | /************************************/ |
| 142 | 152 | /* Write LSB of engine sound */ |
| 143 | 153 | /************************************/ |
| 144 | | WRITE8_DEVICE_HANDLER( polepos_engine_sound_lsb_w ) |
| 154 | WRITE8_MEMBER( polepos_sound_device::polepos_engine_sound_lsb_w ) |
| 145 | 155 | { |
| 146 | | polepos_sound_state *state = get_safe_token(device); |
| 147 | 156 | /* Update stream first so all samples at old frequency are updated. */ |
| 148 | | state->m_stream->update(); |
| 149 | | state->m_sample_lsb = data & 62; |
| 150 | | state->m_sample_enable = data & 1; |
| 157 | m_stream->update(); |
| 158 | m_sample_lsb = data & 62; |
| 159 | m_sample_enable = data & 1; |
| 151 | 160 | } |
| 152 | 161 | |
| 153 | 162 | /************************************/ |
| 154 | 163 | /* Write MSB of engine sound */ |
| 155 | 164 | /************************************/ |
| 156 | | WRITE8_DEVICE_HANDLER( polepos_engine_sound_msb_w ) |
| 165 | WRITE8_MEMBER( polepos_sound_device::polepos_engine_sound_msb_w ) |
| 157 | 166 | { |
| 158 | | polepos_sound_state *state = get_safe_token(device); |
| 159 | | state->m_stream->update(); |
| 160 | | state->m_sample_msb = data & 63; |
| 167 | m_stream->update(); |
| 168 | m_sample_msb = data & 63; |
| 161 | 169 | } |
| 162 | 170 | |
| 163 | 171 | |
| r21254 | r21255 | |
| 178 | 186 | #define POLEPOS_54XX_DAC_R (1.0 / (1.0 / RES_K(47) + 1.0 / RES_K(22) + 1.0 / RES_K(10) + 1.0 / RES_K(4.7))) |
| 179 | 187 | static const discrete_dac_r1_ladder polepos_54xx_dac = |
| 180 | 188 | { |
| 181 | | 4, /* number of DAC bits */ |
| 182 | | /* 54XX_0 54XX_1 54XX_2 */ |
| 183 | | { RES_K(47), /* R124, R136, R152 */ |
| 184 | | RES_K(22), /* R120, R132, R142 */ |
| 185 | | RES_K(10), /* R119, R131, R138 */ |
| 186 | | RES_K(4.7)}, /* R118, R126, R103 */ |
| 187 | | 0, 0, 0, 0 /* nothing extra */ |
| 189 | 4, /* number of DAC bits */ |
| 190 | /* 54XX_0 54XX_1 54XX_2 */ |
| 191 | { RES_K(47), /* R124, R136, R152 */ |
| 192 | RES_K(22), /* R120, R132, R142 */ |
| 193 | RES_K(10), /* R119, R131, R138 */ |
| 194 | RES_K(4.7)}, /* R118, R126, R103 */ |
| 195 | 0, 0, 0, 0 /* nothing extra */ |
| 188 | 196 | }; |
| 189 | 197 | |
| 190 | 198 | #define POLEPOS_52XX_DAC_R (1.0 / (1.0 / RES_K(100) + 1.0 / RES_K(47) + 1.0 / RES_K(22) + 1.0 / RES_K(10))) |
| r21254 | r21255 | |
| 246 | 254 | 0 /* vN */ |
| 247 | 255 | }; |
| 248 | 256 | |
| 257 | |
| 249 | 258 | DISCRETE_SOUND_START(polepos) |
| 250 | 259 | |
| 251 | 260 | /************************************************ |
| r21254 | r21255 | |
| 350 | 359 | DISCRETE_SOUND_END |
| 351 | 360 | |
| 352 | 361 | |
| 353 | | const device_type POLEPOS = &device_creator<polepos_sound_device>; |
| 354 | | |
| 355 | | polepos_sound_device::polepos_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 356 | | : device_t(mconfig, POLEPOS, "Pole Position Custom", tag, owner, clock), |
| 357 | | device_sound_interface(mconfig, *this) |
| 358 | | { |
| 359 | | m_token = global_alloc_clear(polepos_sound_state); |
| 360 | | } |
| 361 | | |
| 362 | | //------------------------------------------------- |
| 363 | | // device_config_complete - perform any |
| 364 | | // operations now that the configuration is |
| 365 | | // complete |
| 366 | | //------------------------------------------------- |
| 367 | | |
| 368 | | void polepos_sound_device::device_config_complete() |
| 369 | | { |
| 370 | | } |
| 371 | | |
| 372 | | //------------------------------------------------- |
| 373 | | // device_start - device-specific startup |
| 374 | | //------------------------------------------------- |
| 375 | | |
| 376 | | void polepos_sound_device::device_start() |
| 377 | | { |
| 378 | | DEVICE_START_NAME( polepos_sound )(this); |
| 379 | | } |
| 380 | | |
| 381 | | //------------------------------------------------- |
| 382 | | // device_reset - device-specific reset |
| 383 | | //------------------------------------------------- |
| 384 | | |
| 385 | | void polepos_sound_device::device_reset() |
| 386 | | { |
| 387 | | DEVICE_RESET_NAME( polepos_sound )(this); |
| 388 | | } |
| 389 | | |
| 390 | | //------------------------------------------------- |
| 391 | | // sound_stream_update - handle a stream update |
| 392 | | //------------------------------------------------- |
| 393 | | |
| 394 | | void polepos_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 395 | | { |
| 396 | | // should never get here |
| 397 | | fatalerror("sound_stream_update called; not applicable to legacy sound devices\n"); |
| 398 | | } |
trunk/src/mame/audio/gridlee.c
| r21254 | r21255 | |
| 6 | 6 | |
| 7 | 7 | #include "emu.h" |
| 8 | 8 | #include "includes/gridlee.h" |
| 9 | | #include "sound/samples.h" |
| 10 | 9 | |
| 11 | 10 | |
| 12 | | /************************************* |
| 13 | | * |
| 14 | | * Structures |
| 15 | | * |
| 16 | | *************************************/ |
| 11 | // device type definition |
| 12 | const device_type GRIDLEE = &device_creator<gridlee_sound_device>; |
| 17 | 13 | |
| 18 | | struct gridlee_sound_state |
| 19 | | { |
| 20 | | /* tone variables */ |
| 21 | | UINT32 m_tone_step; |
| 22 | | UINT32 m_tone_fraction; |
| 23 | | UINT8 m_tone_volume; |
| 24 | 14 | |
| 25 | | /* sound streaming variables */ |
| 26 | | sound_stream *m_stream; |
| 27 | | samples_device *m_samples; |
| 28 | | double m_freq_to_step; |
| 29 | | UINT8 m_sound_data[24]; |
| 30 | | }; |
| 15 | //************************************************************************** |
| 16 | // LIVE DEVICE |
| 17 | //************************************************************************** |
| 31 | 18 | |
| 19 | //------------------------------------------------- |
| 20 | // gridlee_sound_device - constructor |
| 21 | //------------------------------------------------- |
| 32 | 22 | |
| 33 | | /************************************* |
| 34 | | * |
| 35 | | * Core sound generation |
| 36 | | * |
| 37 | | *************************************/ |
| 23 | gridlee_sound_device::gridlee_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 24 | : device_t(mconfig, GRIDLEE, "Gridlee Custom", tag, owner, clock), |
| 25 | device_sound_interface(mconfig, *this), |
| 26 | m_tone_step(0), |
| 27 | m_tone_fraction(0), |
| 28 | m_tone_volume(0), |
| 29 | m_stream(NULL), |
| 30 | m_samples(NULL), |
| 31 | m_freq_to_step(0.0) |
| 32 | { |
| 33 | memset(m_sound_data, 0, sizeof(UINT8)*24); |
| 34 | } |
| 38 | 35 | |
| 39 | | INLINE gridlee_sound_state *get_safe_token( device_t *device ) |
| 36 | |
| 37 | //------------------------------------------------- |
| 38 | // device_start - device-specific startup |
| 39 | //------------------------------------------------- |
| 40 | |
| 41 | void gridlee_sound_device::device_start() |
| 40 | 42 | { |
| 41 | | assert(device != NULL); |
| 42 | | assert(device->type() == GRIDLEE); |
| 43 | /* allocate the stream */ |
| 44 | m_stream = stream_alloc(0, 1, machine().sample_rate()); |
| 43 | 45 | |
| 44 | | return (gridlee_sound_state *)downcast<gridlee_sound_device *>(device)->token(); |
| 46 | m_samples = machine().device<samples_device>("samples"); |
| 47 | |
| 48 | m_freq_to_step = (double)(1 << 24) / (double)machine().sample_rate(); |
| 45 | 49 | } |
| 46 | 50 | |
| 47 | | static STREAM_UPDATE( gridlee_stream_update ) |
| 51 | |
| 52 | //------------------------------------------------- |
| 53 | // sound_stream_update - handle a stream update |
| 54 | //------------------------------------------------- |
| 55 | |
| 56 | void gridlee_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 48 | 57 | { |
| 49 | | gridlee_sound_state *state = get_safe_token(device); |
| 50 | 58 | stream_sample_t *buffer = outputs[0]; |
| 51 | 59 | |
| 52 | 60 | /* loop over samples */ |
| 53 | 61 | while (samples--) |
| 54 | 62 | { |
| 55 | 63 | /* tone channel */ |
| 56 | | state->m_tone_fraction += state->m_tone_step; |
| 57 | | *buffer++ = (state->m_tone_fraction & 0x0800000) ? (state->m_tone_volume << 6) : 0; |
| 64 | m_tone_fraction += m_tone_step; |
| 65 | *buffer++ = (m_tone_fraction & 0x0800000) ? (m_tone_volume << 6) : 0; |
| 58 | 66 | } |
| 59 | 67 | } |
| 60 | 68 | |
| 61 | 69 | |
| 62 | 70 | |
| 63 | | /************************************* |
| 64 | | * |
| 65 | | * Sound startup routines |
| 66 | | * |
| 67 | | *************************************/ |
| 68 | | |
| 69 | | static DEVICE_START( gridlee_sound ) |
| 71 | WRITE8_MEMBER( gridlee_sound_device::gridlee_sound_w ) |
| 70 | 72 | { |
| 71 | | gridlee_sound_state *state = get_safe_token(device); |
| 72 | | running_machine &machine = device->machine(); |
| 73 | UINT8 *sound_data = m_sound_data; |
| 74 | samples_device *samples = m_samples; |
| 73 | 75 | |
| 74 | | /* allocate the stream */ |
| 75 | | state->m_stream = device->machine().sound().stream_alloc(*device, 0, 1, machine.sample_rate(), NULL, gridlee_stream_update); |
| 76 | m_stream->update(); |
| 76 | 77 | |
| 77 | | state->m_samples = device->machine().device<samples_device>("samples"); |
| 78 | | |
| 79 | | state->m_freq_to_step = (double)(1 << 24) / (double)machine.sample_rate(); |
| 80 | | } |
| 81 | | |
| 82 | | |
| 83 | | WRITE8_DEVICE_HANDLER( gridlee_sound_w ) |
| 84 | | { |
| 85 | | gridlee_sound_state *state = get_safe_token(device); |
| 86 | | UINT8 *sound_data = state->m_sound_data; |
| 87 | | samples_device *samples = state->m_samples; |
| 88 | | |
| 89 | | state->m_stream->update(); |
| 90 | | |
| 91 | 78 | switch (offset) |
| 92 | 79 | { |
| 93 | 80 | case 0x04: |
| r21254 | r21255 | |
| 113 | 100 | |
| 114 | 101 | case 0x08+0x08: |
| 115 | 102 | if (data) |
| 116 | | state->m_tone_step = state->m_freq_to_step * (double)(data * 5); |
| 103 | m_tone_step = m_freq_to_step * (double)(data * 5); |
| 117 | 104 | else |
| 118 | | state->m_tone_step = 0; |
| 105 | m_tone_step = 0; |
| 119 | 106 | break; |
| 120 | 107 | |
| 121 | 108 | case 0x09+0x08: |
| 122 | | state->m_tone_volume = data; |
| 109 | m_tone_volume = data; |
| 123 | 110 | break; |
| 124 | 111 | |
| 125 | 112 | case 0x0b+0x08: |
| r21254 | r21255 | |
| 177 | 164 | } |
| 178 | 165 | #endif |
| 179 | 166 | } |
| 180 | | |
| 181 | | |
| 182 | | const device_type GRIDLEE = &device_creator<gridlee_sound_device>; |
| 183 | | |
| 184 | | gridlee_sound_device::gridlee_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 185 | | : device_t(mconfig, GRIDLEE, "Gridlee Custom", tag, owner, clock), |
| 186 | | device_sound_interface(mconfig, *this) |
| 187 | | { |
| 188 | | m_token = global_alloc_clear(gridlee_sound_state); |
| 189 | | } |
| 190 | | |
| 191 | | //------------------------------------------------- |
| 192 | | // device_config_complete - perform any |
| 193 | | // operations now that the configuration is |
| 194 | | // complete |
| 195 | | //------------------------------------------------- |
| 196 | | |
| 197 | | void gridlee_sound_device::device_config_complete() |
| 198 | | { |
| 199 | | } |
| 200 | | |
| 201 | | //------------------------------------------------- |
| 202 | | // device_start - device-specific startup |
| 203 | | //------------------------------------------------- |
| 204 | | |
| 205 | | void gridlee_sound_device::device_start() |
| 206 | | { |
| 207 | | DEVICE_START_NAME( gridlee_sound )(this); |
| 208 | | } |
| 209 | | |
| 210 | | //------------------------------------------------- |
| 211 | | // sound_stream_update - handle a stream update |
| 212 | | //------------------------------------------------- |
| 213 | | |
| 214 | | void gridlee_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 215 | | { |
| 216 | | // should never get here |
| 217 | | fatalerror("sound_stream_update called; not applicable to legacy sound devices\n"); |
| 218 | | } |
trunk/src/mame/audio/tiamc1.c
| r21254 | r21255 | |
| 37 | 37 | #define CLOCK_DIVIDER 16 |
| 38 | 38 | #define BUF_LEN 100000 |
| 39 | 39 | |
| 40 | | struct timer8253chan { |
| 41 | | UINT16 count; |
| 42 | | UINT16 cnval; |
| 43 | | UINT8 bcdMode; |
| 44 | | UINT8 cntMode; |
| 45 | | UINT8 valMode; |
| 46 | | UINT8 gate; |
| 47 | | UINT8 output; |
| 48 | | UINT8 loadCnt; |
| 49 | | UINT8 enable; |
| 50 | | }; |
| 40 | #define T8253_CHAN0 0 |
| 41 | #define T8253_CHAN1 1 |
| 42 | #define T8253_CHAN2 2 |
| 43 | #define T8253_CWORD 3 |
| 51 | 44 | |
| 52 | | struct timer8253struct { |
| 53 | | struct timer8253chan channel[3]; |
| 54 | | }; |
| 55 | 45 | |
| 56 | | struct tiamc1_sound_state |
| 46 | // device type definition |
| 47 | const device_type TIAMC1 = &device_creator<tiamc1_sound_device>; |
| 48 | |
| 49 | |
| 50 | //************************************************************************** |
| 51 | // LIVE DEVICE |
| 52 | //************************************************************************** |
| 53 | |
| 54 | //------------------------------------------------- |
| 55 | // tiamc1_sound_device - constructor |
| 56 | //------------------------------------------------- |
| 57 | |
| 58 | tiamc1_sound_device::tiamc1_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 59 | : device_t(mconfig, TIAMC1, "TIA-MC1 Custom", tag, owner, clock), |
| 60 | device_sound_interface(mconfig, *this), |
| 61 | m_channel(NULL), |
| 62 | m_timer1_divider(0) |
| 57 | 63 | { |
| 58 | | sound_stream *m_channel; |
| 59 | | int m_timer1_divider; |
| 64 | } |
| 60 | 65 | |
| 61 | | struct timer8253struct m_timer0; |
| 62 | | struct timer8253struct m_timer1; |
| 63 | | }; |
| 64 | 66 | |
| 67 | //------------------------------------------------- |
| 68 | // device_start - device-specific startup |
| 69 | //------------------------------------------------- |
| 65 | 70 | |
| 66 | | #define T8253_CHAN0 0 |
| 67 | | #define T8253_CHAN1 1 |
| 68 | | #define T8253_CHAN2 2 |
| 69 | | #define T8253_CWORD 3 |
| 71 | void tiamc1_sound_device::device_start() |
| 72 | { |
| 73 | int i, j; |
| 70 | 74 | |
| 75 | timer8253_reset(&m_timer0); |
| 76 | timer8253_reset(&m_timer1); |
| 71 | 77 | |
| 72 | | INLINE tiamc1_sound_state *get_safe_token(device_t *device) |
| 78 | m_channel = stream_alloc(0, 1, clock() / CLOCK_DIVIDER); |
| 79 | |
| 80 | m_timer1_divider = 0; |
| 81 | |
| 82 | for (i = 0; i < 2; i++) |
| 83 | { |
| 84 | struct timer8253struct *t = (i ? &m_timer1 : &m_timer0); |
| 85 | |
| 86 | for (j = 0; j < 3; j++) |
| 87 | { |
| 88 | state_save_register_item(machine(), "channel", NULL, i * 3 + j, t->channel[j].count); |
| 89 | state_save_register_item(machine(), "channel", NULL, i * 3 + j, t->channel[j].cnval); |
| 90 | state_save_register_item(machine(), "channel", NULL, i * 3 + j, t->channel[j].bcdMode); |
| 91 | state_save_register_item(machine(), "channel", NULL, i * 3 + j, t->channel[j].cntMode); |
| 92 | state_save_register_item(machine(), "channel", NULL, i * 3 + j, t->channel[j].valMode); |
| 93 | state_save_register_item(machine(), "channel", NULL, i * 3 + j, t->channel[j].gate); |
| 94 | state_save_register_item(machine(), "channel", NULL, i * 3 + j, t->channel[j].output); |
| 95 | state_save_register_item(machine(), "channel", NULL, i * 3 + j, t->channel[j].loadCnt); |
| 96 | state_save_register_item(machine(), "channel", NULL, i * 3 + j, t->channel[j].enable); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | save_item(NAME(m_timer1_divider)); |
| 101 | } |
| 102 | |
| 103 | |
| 104 | //------------------------------------------------- |
| 105 | // sound_stream_update - handle a stream update |
| 106 | //------------------------------------------------- |
| 107 | |
| 108 | void tiamc1_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 73 | 109 | { |
| 74 | | assert(device != NULL); |
| 75 | | assert(device->type() == TIAMC1); |
| 110 | int count, o0, o1, o2, len, orval = 0; |
| 76 | 111 | |
| 77 | | return (tiamc1_sound_state *)downcast<tiamc1_sound_device *>(device)->token(); |
| 112 | len = samples * CLOCK_DIVIDER; |
| 113 | |
| 114 | for (count = 0; count < len; count++) |
| 115 | { |
| 116 | m_timer1_divider++; |
| 117 | if (m_timer1_divider == 228) |
| 118 | { |
| 119 | m_timer1_divider = 0; |
| 120 | timer8253_tick(&m_timer1, 0); |
| 121 | timer8253_tick(&m_timer1, 1); |
| 122 | timer8253_tick(&m_timer1, 2); |
| 123 | |
| 124 | timer8253_set_gate(&m_timer0, 0, timer8253_get_output(&m_timer1, 0)); |
| 125 | timer8253_set_gate(&m_timer0, 1, timer8253_get_output(&m_timer1, 1)); |
| 126 | timer8253_set_gate(&m_timer0, 2, timer8253_get_output(&m_timer1, 2)); |
| 127 | } |
| 128 | |
| 129 | timer8253_tick(&m_timer0, 0); |
| 130 | timer8253_tick(&m_timer0, 1); |
| 131 | timer8253_tick(&m_timer0, 2); |
| 132 | |
| 133 | o0 = timer8253_get_output(&m_timer0, 0) ? 1 : 0; |
| 134 | o1 = timer8253_get_output(&m_timer0, 1) ? 1 : 0; |
| 135 | o2 = timer8253_get_output(&m_timer0, 2) ? 1 : 0; |
| 136 | |
| 137 | orval = (orval << 1) | (((o0 | o1) ^ 0xff) & o2); |
| 138 | |
| 139 | if ((count + 1) % CLOCK_DIVIDER == 0) |
| 140 | { |
| 141 | outputs[0][count / CLOCK_DIVIDER] = orval ? 0x2828 : 0; |
| 142 | orval = 0; |
| 143 | } |
| 144 | } |
| 78 | 145 | } |
| 79 | 146 | |
| 80 | 147 | |
| 81 | | static void timer8253_reset(struct timer8253struct *t) { |
| 82 | | memset(t,0,sizeof(struct timer8253struct)); |
| 148 | void tiamc1_sound_device::timer8253_reset(struct timer8253struct *t) |
| 149 | { |
| 150 | memset(t,0,sizeof(struct timer8253struct)); |
| 83 | 151 | } |
| 84 | 152 | |
| 85 | 153 | |
| 86 | | static void timer8253_tick(struct timer8253struct *t,int chn) { |
| 87 | | if (t->channel[chn].enable && t->channel[chn].gate) { |
| 88 | | switch (t->channel[chn].cntMode) { |
| 154 | void tiamc1_sound_device::timer8253_tick(struct timer8253struct *t, int chn) |
| 155 | { |
| 156 | if (t->channel[chn].enable && t->channel[chn].gate) |
| 157 | { |
| 158 | switch (t->channel[chn].cntMode) |
| 159 | { |
| 89 | 160 | case 0: |
| 90 | 161 | t->channel[chn].count--; |
| 91 | 162 | if (t->channel[chn].count == 0xffff) |
| r21254 | r21255 | |
| 109 | 180 | if(t->channel[chn].count==0) |
| 110 | 181 | t->channel[chn].output = 1; |
| 111 | 182 | |
| 112 | | if(t->channel[chn].count == 0xffff) { |
| 183 | if(t->channel[chn].count == 0xffff) |
| 184 | { |
| 113 | 185 | t->channel[chn].enable = 0; |
| 114 | 186 | t->channel[chn].output = 1; |
| 115 | 187 | } |
| r21254 | r21255 | |
| 120 | 192 | |
| 121 | 193 | |
| 122 | 194 | |
| 123 | | static void timer8253_wr(struct timer8253struct *t, int reg, UINT8 val) |
| 195 | void tiamc1_sound_device::timer8253_wr(struct timer8253struct *t, int reg, UINT8 val) |
| 124 | 196 | { |
| 125 | 197 | int chn; |
| 126 | 198 | |
| 127 | | switch (reg) { |
| 199 | switch (reg) |
| 200 | { |
| 128 | 201 | case T8253_CWORD: |
| 129 | 202 | chn = val >> 6; |
| 130 | | if (chn < 3) { |
| 203 | if (chn < 3) |
| 204 | { |
| 131 | 205 | t->channel[chn].bcdMode = (val & 1) ? 1 : 0; |
| 132 | 206 | t->channel[chn].cntMode = (val >> 1) & 0x07; |
| 133 | 207 | t->channel[chn].valMode = (val >> 4) & 0x03; |
| 134 | 208 | |
| 135 | | switch (t->channel[chn].valMode) { |
| 209 | switch (t->channel[chn].valMode) |
| 210 | { |
| 136 | 211 | case 1: |
| 137 | 212 | case 2: |
| 138 | 213 | t->channel[chn].loadCnt = 1; |
| r21254 | r21255 | |
| 146 | 221 | mame_printf_debug("unhandled val mode %i\n", t->channel[chn].valMode); |
| 147 | 222 | } |
| 148 | 223 | |
| 149 | | switch (t->channel[chn].cntMode) { |
| 224 | switch (t->channel[chn].cntMode) |
| 225 | { |
| 150 | 226 | case 0: |
| 151 | 227 | t->channel[chn].output = 0; |
| 152 | 228 | t->channel[chn].enable = 0; |
| r21254 | r21255 | |
| 170 | 246 | default: |
| 171 | 247 | chn = reg; |
| 172 | 248 | |
| 173 | | switch (t->channel[chn].valMode) { |
| 249 | switch (t->channel[chn].valMode) |
| 250 | { |
| 174 | 251 | case 1: |
| 175 | 252 | t->channel[chn].cnval = (t->channel[chn].cnval & 0xff00) | val; |
| 176 | 253 | break; |
| r21254 | r21255 | |
| 184 | 261 | mame_printf_debug("unhandled val mode %i\n", t->channel[chn].valMode); |
| 185 | 262 | } |
| 186 | 263 | |
| 187 | | if (t->channel[chn].cntMode==0) { |
| 264 | if (t->channel[chn].cntMode==0) |
| 265 | { |
| 188 | 266 | t->channel[chn].enable = 0; |
| 189 | 267 | } |
| 190 | 268 | |
| 191 | 269 | t->channel[chn].loadCnt--; |
| 192 | 270 | |
| 193 | | if (t->channel[chn].loadCnt == 0) { |
| 194 | | switch (t->channel[chn].valMode) { |
| 271 | if (t->channel[chn].loadCnt == 0) |
| 272 | { |
| 273 | switch (t->channel[chn].valMode) |
| 274 | { |
| 195 | 275 | case 1: |
| 196 | 276 | case 2: |
| 197 | 277 | t->channel[chn].loadCnt = 1; |
| r21254 | r21255 | |
| 205 | 285 | mame_printf_debug("unhandled val mode %i\n", t->channel[chn].valMode); |
| 206 | 286 | } |
| 207 | 287 | |
| 208 | | switch (t->channel[chn].cntMode) { |
| 288 | switch (t->channel[chn].cntMode) |
| 289 | { |
| 209 | 290 | case 3: |
| 210 | 291 | t->channel[chn].count = t->channel[chn].cnval; |
| 211 | 292 | t->channel[chn].enable = 1; |
| r21254 | r21255 | |
| 224 | 305 | } |
| 225 | 306 | } |
| 226 | 307 | |
| 227 | | static void timer8253_set_gate(struct timer8253struct *t, int chn, UINT8 gate) |
| 308 | void tiamc1_sound_device::timer8253_set_gate(struct timer8253struct *t, int chn, UINT8 gate) |
| 228 | 309 | { |
| 229 | 310 | t->channel[chn].gate = gate; |
| 230 | 311 | } |
| 231 | 312 | |
| 232 | 313 | |
| 233 | 314 | |
| 234 | | static char timer8253_get_output(struct timer8253struct *t, int chn) |
| 315 | char tiamc1_sound_device::timer8253_get_output(struct timer8253struct *t, int chn) |
| 235 | 316 | { |
| 236 | 317 | return t->channel[chn].output; |
| 237 | 318 | } |
| 238 | 319 | |
| 239 | 320 | |
| 240 | 321 | |
| 241 | | WRITE8_DEVICE_HANDLER( tiamc1_timer0_w ) |
| 322 | WRITE8_MEMBER( tiamc1_sound_device::tiamc1_timer0_w ) |
| 242 | 323 | { |
| 243 | | tiamc1_sound_state *state = get_safe_token(device); |
| 244 | | timer8253_wr(&state->m_timer0, offset, data); |
| 324 | timer8253_wr(&m_timer0, offset, data); |
| 245 | 325 | } |
| 246 | 326 | |
| 247 | | WRITE8_DEVICE_HANDLER( tiamc1_timer1_w ) |
| 327 | WRITE8_MEMBER( tiamc1_sound_device::tiamc1_timer1_w ) |
| 248 | 328 | { |
| 249 | | tiamc1_sound_state *state = get_safe_token(device); |
| 250 | | timer8253_wr(&state->m_timer1, offset, data); |
| 329 | timer8253_wr(&m_timer1, offset, data); |
| 251 | 330 | } |
| 252 | 331 | |
| 253 | | WRITE8_DEVICE_HANDLER( tiamc1_timer1_gate_w ) |
| 332 | WRITE8_MEMBER( tiamc1_sound_device::tiamc1_timer1_gate_w ) |
| 254 | 333 | { |
| 255 | | tiamc1_sound_state *state = get_safe_token(device); |
| 256 | | timer8253_set_gate(&state->m_timer1, 0, (data & 1) ? 1 : 0); |
| 257 | | timer8253_set_gate(&state->m_timer1, 1, (data & 2) ? 1 : 0); |
| 258 | | timer8253_set_gate(&state->m_timer1, 2, (data & 4) ? 1 : 0); |
| 334 | timer8253_set_gate(&m_timer1, 0, (data & 1) ? 1 : 0); |
| 335 | timer8253_set_gate(&m_timer1, 1, (data & 2) ? 1 : 0); |
| 336 | timer8253_set_gate(&m_timer1, 2, (data & 4) ? 1 : 0); |
| 259 | 337 | } |
| 260 | | |
| 261 | | |
| 262 | | static STREAM_UPDATE( tiamc1_sound_update ) |
| 263 | | { |
| 264 | | tiamc1_sound_state *state = get_safe_token(device); |
| 265 | | int count, o0, o1, o2, len, orval = 0; |
| 266 | | |
| 267 | | len = samples * CLOCK_DIVIDER; |
| 268 | | |
| 269 | | for (count = 0; count < len; count++) { |
| 270 | | state->m_timer1_divider++; |
| 271 | | if (state->m_timer1_divider == 228) { |
| 272 | | state->m_timer1_divider = 0; |
| 273 | | timer8253_tick(&state->m_timer1, 0); |
| 274 | | timer8253_tick(&state->m_timer1, 1); |
| 275 | | timer8253_tick(&state->m_timer1, 2); |
| 276 | | |
| 277 | | timer8253_set_gate(&state->m_timer0, 0, timer8253_get_output(&state->m_timer1, 0)); |
| 278 | | timer8253_set_gate(&state->m_timer0, 1, timer8253_get_output(&state->m_timer1, 1)); |
| 279 | | timer8253_set_gate(&state->m_timer0, 2, timer8253_get_output(&state->m_timer1, 2)); |
| 280 | | } |
| 281 | | |
| 282 | | timer8253_tick(&state->m_timer0, 0); |
| 283 | | timer8253_tick(&state->m_timer0, 1); |
| 284 | | timer8253_tick(&state->m_timer0, 2); |
| 285 | | |
| 286 | | o0 = timer8253_get_output(&state->m_timer0, 0) ? 1 : 0; |
| 287 | | o1 = timer8253_get_output(&state->m_timer0, 1) ? 1 : 0; |
| 288 | | o2 = timer8253_get_output(&state->m_timer0, 2) ? 1 : 0; |
| 289 | | |
| 290 | | orval = (orval << 1) | (((o0 | o1) ^ 0xff) & o2); |
| 291 | | |
| 292 | | if ((count + 1) % CLOCK_DIVIDER == 0) { |
| 293 | | outputs[0][count / CLOCK_DIVIDER] = orval ? 0x2828 : 0; |
| 294 | | orval = 0; |
| 295 | | } |
| 296 | | } |
| 297 | | } |
| 298 | | |
| 299 | | static DEVICE_START( tiamc1_sound ) |
| 300 | | { |
| 301 | | tiamc1_sound_state *state = get_safe_token(device); |
| 302 | | running_machine &machine = device->machine(); |
| 303 | | int i, j; |
| 304 | | |
| 305 | | timer8253_reset(&state->m_timer0); |
| 306 | | timer8253_reset(&state->m_timer1); |
| 307 | | |
| 308 | | state->m_channel = device->machine().sound().stream_alloc(*device, 0, 1, device->clock() / CLOCK_DIVIDER, 0, tiamc1_sound_update); |
| 309 | | |
| 310 | | state->m_timer1_divider = 0; |
| 311 | | |
| 312 | | for (i = 0; i < 2; i++) { |
| 313 | | struct timer8253struct *t = (i ? &state->m_timer1 : &state->m_timer0); |
| 314 | | |
| 315 | | for (j = 0; j < 3; j++) { |
| 316 | | state_save_register_item(machine, "channel", NULL, i * 3 + j, t->channel[j].count); |
| 317 | | state_save_register_item(machine, "channel", NULL, i * 3 + j, t->channel[j].cnval); |
| 318 | | state_save_register_item(machine, "channel", NULL, i * 3 + j, t->channel[j].bcdMode); |
| 319 | | state_save_register_item(machine, "channel", NULL, i * 3 + j, t->channel[j].cntMode); |
| 320 | | state_save_register_item(machine, "channel", NULL, i * 3 + j, t->channel[j].valMode); |
| 321 | | state_save_register_item(machine, "channel", NULL, i * 3 + j, t->channel[j].gate); |
| 322 | | state_save_register_item(machine, "channel", NULL, i * 3 + j, t->channel[j].output); |
| 323 | | state_save_register_item(machine, "channel", NULL, i * 3 + j, t->channel[j].loadCnt); |
| 324 | | state_save_register_item(machine, "channel", NULL, i * 3 + j, t->channel[j].enable); |
| 325 | | } |
| 326 | | } |
| 327 | | |
| 328 | | device->save_item(NAME(state->m_timer1_divider)); |
| 329 | | } |
| 330 | | |
| 331 | | |
| 332 | | const device_type TIAMC1 = &device_creator<tiamc1_sound_device>; |
| 333 | | |
| 334 | | tiamc1_sound_device::tiamc1_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 335 | | : device_t(mconfig, TIAMC1, "TIA-MC1 Custom", tag, owner, clock), |
| 336 | | device_sound_interface(mconfig, *this) |
| 337 | | { |
| 338 | | m_token = global_alloc_clear(tiamc1_sound_state); |
| 339 | | } |
| 340 | | |
| 341 | | //------------------------------------------------- |
| 342 | | // device_config_complete - perform any |
| 343 | | // operations now that the configuration is |
| 344 | | // complete |
| 345 | | //------------------------------------------------- |
| 346 | | |
| 347 | | void tiamc1_sound_device::device_config_complete() |
| 348 | | { |
| 349 | | } |
| 350 | | |
| 351 | | //------------------------------------------------- |
| 352 | | // device_start - device-specific startup |
| 353 | | //------------------------------------------------- |
| 354 | | |
| 355 | | void tiamc1_sound_device::device_start() |
| 356 | | { |
| 357 | | DEVICE_START_NAME( tiamc1_sound )(this); |
| 358 | | } |
| 359 | | |
| 360 | | //------------------------------------------------- |
| 361 | | // sound_stream_update - handle a stream update |
| 362 | | //------------------------------------------------- |
| 363 | | |
| 364 | | void tiamc1_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 365 | | { |
| 366 | | // should never get here |
| 367 | | fatalerror("sound_stream_update called; not applicable to legacy sound devices\n"); |
| 368 | | } |
trunk/src/mame/audio/cps3.c
| r21254 | r21255 | |
| 6 | 6 | #include "emu.h" |
| 7 | 7 | #include "includes/cps3.h" |
| 8 | 8 | |
| 9 | | #define CPS3_VOICES 16 |
| 10 | 9 | |
| 11 | | struct cps3_voice |
| 12 | | { |
| 13 | | UINT32 regs[8]; |
| 14 | | UINT32 pos; |
| 15 | | UINT16 frac; |
| 16 | | }; |
| 10 | // device type definition |
| 11 | const device_type CPS3 = &device_creator<cps3_sound_device>; |
| 17 | 12 | |
| 18 | | struct cps3_sound_state |
| 19 | | { |
| 20 | | sound_stream *m_stream; |
| 21 | | cps3_voice m_voice[CPS3_VOICES]; |
| 22 | | UINT16 m_key; |
| 23 | | INT8* m_base; |
| 24 | | }; |
| 25 | 13 | |
| 26 | | INLINE cps3_sound_state *get_safe_token(device_t *device) |
| 14 | //************************************************************************** |
| 15 | // LIVE DEVICE |
| 16 | //************************************************************************** |
| 17 | |
| 18 | //------------------------------------------------- |
| 19 | // cps3_sound_device - constructor |
| 20 | //------------------------------------------------- |
| 21 | |
| 22 | cps3_sound_device::cps3_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 23 | : device_t(mconfig, CPS3, "CPS3 Custom", tag, owner, clock), |
| 24 | device_sound_interface(mconfig, *this), |
| 25 | m_stream(NULL), |
| 26 | m_key(0), |
| 27 | m_base(NULL) |
| 27 | 28 | { |
| 28 | | assert(device != NULL); |
| 29 | | assert(device->type() == CPS3); |
| 29 | } |
| 30 | 30 | |
| 31 | | return (cps3_sound_state *)downcast<cps3_sound_device *>(device)->token(); |
| 31 | |
| 32 | //------------------------------------------------- |
| 33 | // device_start - device-specific startup |
| 34 | //------------------------------------------------- |
| 35 | |
| 36 | void cps3_sound_device::device_start() |
| 37 | { |
| 38 | /* Allocate the stream */ |
| 39 | m_stream = stream_alloc(0, 2, clock() / 384); |
| 32 | 40 | } |
| 33 | 41 | |
| 34 | | static STREAM_UPDATE( cps3_stream_update ) |
| 42 | |
| 43 | //------------------------------------------------- |
| 44 | // sound_stream_update - handle a stream update |
| 45 | //------------------------------------------------- |
| 46 | |
| 47 | void cps3_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 35 | 48 | { |
| 36 | | cps3_sound_state *state = get_safe_token(device); |
| 37 | 49 | int i; |
| 38 | 50 | |
| 39 | 51 | // the actual 'user5' region only exists on the nocd sets, on the others it's allocated in the initialization. |
| 40 | 52 | // it's a shared gfx/sound region, so can't be allocated as part of the sound device. |
| 41 | | state->m_base = (INT8*)device->machine().driver_data<cps3_state>()->m_user5region; |
| 53 | m_base = (INT8*)machine().driver_data<cps3_state>()->m_user5region; |
| 42 | 54 | |
| 43 | 55 | /* Clear the buffers */ |
| 44 | 56 | memset(outputs[0], 0, samples*sizeof(*outputs[0])); |
| r21254 | r21255 | |
| 46 | 58 | |
| 47 | 59 | for (i = 0; i < CPS3_VOICES; i ++) |
| 48 | 60 | { |
| 49 | | if (state->m_key & (1 << i)) |
| 61 | if (m_key & (1 << i)) |
| 50 | 62 | { |
| 51 | 63 | int j; |
| 52 | 64 | |
| 53 | 65 | /* TODO */ |
| 54 | 66 | #define SWAP(a) ((a >> 16) | ((a & 0xffff) << 16)) |
| 55 | 67 | |
| 56 | | cps3_voice *vptr = &state->m_voice[i]; |
| 68 | cps3_voice *vptr = &m_voice[i]; |
| 57 | 69 | |
| 58 | 70 | UINT32 start = vptr->regs[1]; |
| 59 | 71 | UINT32 end = vptr->regs[5]; |
| r21254 | r21255 | |
| 88 | 100 | } |
| 89 | 101 | else |
| 90 | 102 | { |
| 91 | | state->m_key &= ~(1 << i); |
| 103 | m_key &= ~(1 << i); |
| 92 | 104 | break; |
| 93 | 105 | } |
| 94 | 106 | } |
| 95 | 107 | |
| 96 | | sample = state->m_base[BYTE4_XOR_LE(start + pos)]; |
| 108 | sample = m_base[BYTE4_XOR_LE(start + pos)]; |
| 97 | 109 | frac += step; |
| 98 | 110 | |
| 99 | 111 | outputs[0][j] += (sample * (vol_l >> 8)); |
| r21254 | r21255 | |
| 104 | 116 | vptr->frac = frac; |
| 105 | 117 | } |
| 106 | 118 | } |
| 107 | | |
| 108 | 119 | } |
| 109 | 120 | |
| 110 | | static DEVICE_START( cps3_sound ) |
| 111 | | { |
| 112 | | cps3_sound_state *state = get_safe_token(device); |
| 113 | 121 | |
| 114 | | /* Allocate the stream */ |
| 115 | | state->m_stream = device->machine().sound().stream_alloc(*device, 0, 2, device->clock() / 384, NULL, cps3_stream_update); |
| 116 | | } |
| 117 | | |
| 118 | | WRITE32_DEVICE_HANDLER( cps3_sound_w ) |
| 122 | WRITE32_MEMBER( cps3_sound_device::cps3_sound_w ) |
| 119 | 123 | { |
| 120 | | cps3_sound_state *state = get_safe_token(device); |
| 124 | m_stream->update(); |
| 121 | 125 | |
| 122 | | state->m_stream->update(); |
| 123 | | |
| 124 | 126 | if (offset < 0x80) |
| 125 | 127 | { |
| 126 | | COMBINE_DATA(&state->m_voice[offset / 8].regs[offset & 7]); |
| 128 | COMBINE_DATA(&m_voice[offset / 8].regs[offset & 7]); |
| 127 | 129 | } |
| 128 | 130 | else if (offset == 0x80) |
| 129 | 131 | { |
| r21254 | r21255 | |
| 133 | 135 | for (i = 0; i < CPS3_VOICES; i++) |
| 134 | 136 | { |
| 135 | 137 | // Key off -> Key on |
| 136 | | if ((key & (1 << i)) && !(state->m_key & (1 << i))) |
| 138 | if ((key & (1 << i)) && !(m_key & (1 << i))) |
| 137 | 139 | { |
| 138 | | state->m_voice[i].frac = 0; |
| 139 | | state->m_voice[i].pos = 0; |
| 140 | m_voice[i].frac = 0; |
| 141 | m_voice[i].pos = 0; |
| 140 | 142 | } |
| 141 | 143 | } |
| 142 | | state->m_key = key; |
| 144 | m_key = key; |
| 143 | 145 | } |
| 144 | 146 | else |
| 145 | 147 | { |
| r21254 | r21255 | |
| 148 | 150 | } |
| 149 | 151 | } |
| 150 | 152 | |
| 151 | | READ32_DEVICE_HANDLER( cps3_sound_r ) |
| 153 | |
| 154 | READ32_MEMBER( cps3_sound_device::cps3_sound_r ) |
| 152 | 155 | { |
| 153 | | cps3_sound_state *state = get_safe_token(device); |
| 154 | | state->m_stream->update(); |
| 156 | m_stream->update(); |
| 155 | 157 | |
| 156 | 158 | if (offset < 0x80) |
| 157 | 159 | { |
| 158 | | return state->m_voice[offset / 8].regs[offset & 7] & mem_mask; |
| 160 | return m_voice[offset / 8].regs[offset & 7] & mem_mask; |
| 159 | 161 | } |
| 160 | 162 | else if (offset == 0x80) |
| 161 | 163 | { |
| 162 | | return state->m_key << 16; |
| 164 | return m_key << 16; |
| 163 | 165 | } |
| 164 | 166 | else |
| 165 | 167 | { |
| r21254 | r21255 | |
| 167 | 169 | return 0; |
| 168 | 170 | } |
| 169 | 171 | } |
| 170 | | |
| 171 | | |
| 172 | | const device_type CPS3 = &device_creator<cps3_sound_device>; |
| 173 | | |
| 174 | | cps3_sound_device::cps3_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 175 | | : device_t(mconfig, CPS3, "CPS3 Custom", tag, owner, clock), |
| 176 | | device_sound_interface(mconfig, *this) |
| 177 | | { |
| 178 | | m_token = global_alloc_clear(cps3_sound_state); |
| 179 | | } |
| 180 | | |
| 181 | | //------------------------------------------------- |
| 182 | | // device_config_complete - perform any |
| 183 | | // operations now that the configuration is |
| 184 | | // complete |
| 185 | | //------------------------------------------------- |
| 186 | | |
| 187 | | void cps3_sound_device::device_config_complete() |
| 188 | | { |
| 189 | | } |
| 190 | | |
| 191 | | //------------------------------------------------- |
| 192 | | // device_start - device-specific startup |
| 193 | | //------------------------------------------------- |
| 194 | | |
| 195 | | void cps3_sound_device::device_start() |
| 196 | | { |
| 197 | | DEVICE_START_NAME( cps3_sound )(this); |
| 198 | | } |
| 199 | | |
| 200 | | //------------------------------------------------- |
| 201 | | // sound_stream_update - handle a stream update |
| 202 | | //------------------------------------------------- |
| 203 | | |
| 204 | | void cps3_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 205 | | { |
| 206 | | // should never get here |
| 207 | | fatalerror("sound_stream_update called; not applicable to legacy sound devices\n"); |
| 208 | | } |
trunk/src/mame/audio/redbaron.c
| r21254 | r21255 | |
| 1 | 1 | /************************************************************************* |
| 2 | 2 | |
| 3 | | Atari Red Baron hardware |
| 3 | Atari Red Baron sound hardware |
| 4 | 4 | |
| 5 | 5 | *************************************************************************/ |
| 6 | 6 | /* |
| r21254 | r21255 | |
| 20 | 20 | |
| 21 | 21 | #define OUTPUT_RATE (48000) |
| 22 | 22 | |
| 23 | | struct redbaron_sound_state |
| 24 | | { |
| 25 | | INT16 *m_vol_lookup; |
| 26 | 23 | |
| 27 | | INT16 m_vol_crash[16]; |
| 24 | // device type definition |
| 25 | const device_type REDBARON = &device_creator<redbaron_sound_device>; |
| 28 | 26 | |
| 29 | | sound_stream *m_channel; |
| 30 | | int m_latch; |
| 31 | | int m_poly_counter; |
| 32 | | int m_poly_shift; |
| 33 | 27 | |
| 34 | | int m_filter_counter; |
| 28 | //************************************************************************** |
| 29 | // LIVE DEVICE |
| 30 | //************************************************************************** |
| 35 | 31 | |
| 36 | | int m_crash_amp; |
| 37 | | int m_shot_amp; |
| 38 | | int m_shot_amp_counter; |
| 32 | //------------------------------------------------- |
| 33 | // redbaron_sound_device - constructor |
| 34 | //------------------------------------------------- |
| 39 | 35 | |
| 40 | | int m_squeal_amp; |
| 41 | | int m_squeal_amp_counter; |
| 42 | | int m_squeal_off_counter; |
| 43 | | int m_squeal_on_counter; |
| 44 | | int m_squeal_out; |
| 45 | | }; |
| 46 | | |
| 47 | | INLINE redbaron_sound_state *get_safe_token(device_t *device) |
| 36 | redbaron_sound_device::redbaron_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 37 | : device_t(mconfig, REDBARON, "Red Baron Custom", tag, owner, clock), |
| 38 | device_sound_interface(mconfig, *this), |
| 39 | m_vol_lookup(NULL), |
| 40 | m_channel(NULL), |
| 41 | m_latch(0), |
| 42 | m_poly_counter(0), |
| 43 | m_poly_shift(0), |
| 44 | m_filter_counter(0), |
| 45 | m_crash_amp(0), |
| 46 | m_shot_amp(0), |
| 47 | m_shot_amp_counter(0), |
| 48 | m_squeal_amp(0), |
| 49 | m_squeal_amp_counter(0), |
| 50 | m_squeal_off_counter(0), |
| 51 | m_squeal_on_counter(0), |
| 52 | m_squeal_out(0) |
| 48 | 53 | { |
| 49 | | assert(device != NULL); |
| 50 | | assert(device->type() == REDBARON); |
| 51 | | |
| 52 | | return (redbaron_sound_state *)downcast<redbaron_sound_device *>(device)->token(); |
| 54 | memset(m_vol_crash, 0, sizeof(INT16)*16); |
| 53 | 55 | } |
| 54 | 56 | |
| 55 | 57 | |
| 56 | | WRITE8_DEVICE_HANDLER( redbaron_sounds_w ) |
| 58 | //------------------------------------------------- |
| 59 | // device_start - device-specific startup |
| 60 | //------------------------------------------------- |
| 61 | |
| 62 | void redbaron_sound_device::device_start() |
| 57 | 63 | { |
| 58 | | redbaron_sound_state *state = get_safe_token(device); |
| 64 | int i; |
| 59 | 65 | |
| 60 | | /* If sound is off, don't bother playing samples */ |
| 61 | | if( data == state->m_latch ) |
| 62 | | return; |
| 66 | m_vol_lookup = auto_alloc_array(machine(), INT16, 32768); |
| 67 | for( i = 0; i < 0x8000; i++ ) |
| 68 | m_vol_lookup[0x7fff-i] = (INT16) (0x7fff/exp(1.0*i/4096)); |
| 63 | 69 | |
| 64 | | state->m_channel->update(); |
| 65 | | state->m_latch = data; |
| 66 | | } |
| 70 | for( i = 0; i < 16; i++ ) |
| 71 | { |
| 72 | /* r0 = R18 and R24, r1 = open */ |
| 73 | double r0 = 1.0/(5600 + 680), r1 = 1/6e12; |
| 67 | 74 | |
| 68 | | #ifdef UNUSED_FUNCTION |
| 69 | | WRITE8_DEVICE_HANDLER( redbaron_pokey_w ) |
| 70 | | { |
| 71 | | redbaron_sound_state *state = get_safe_token(device); |
| 75 | /* R14 */ |
| 76 | if( i & 1 ) |
| 77 | r1 += 1.0/8200; |
| 78 | else |
| 79 | r0 += 1.0/8200; |
| 80 | /* R15 */ |
| 81 | if( i & 2 ) |
| 82 | r1 += 1.0/3900; |
| 83 | else |
| 84 | r0 += 1.0/3900; |
| 85 | /* R16 */ |
| 86 | if( i & 4 ) |
| 87 | r1 += 1.0/2200; |
| 88 | else |
| 89 | r0 += 1.0/2200; |
| 90 | /* R17 */ |
| 91 | if( i & 8 ) |
| 92 | r1 += 1.0/1000; |
| 93 | else |
| 94 | r0 += 1.0/1000; |
| 95 | r0 = 1.0/r0; |
| 96 | r1 = 1.0/r1; |
| 97 | m_vol_crash[i] = 32767 * r0 / (r0 + r1); |
| 98 | } |
| 72 | 99 | |
| 73 | | if( state->m_latch & 0x20 ) |
| 74 | | pokey_w(device, offset, data); |
| 100 | m_channel = stream_alloc(0, 1, OUTPUT_RATE); |
| 75 | 101 | } |
| 76 | | #endif |
| 77 | 102 | |
| 78 | | static STREAM_UPDATE( redbaron_sound_update ) |
| 103 | |
| 104 | |
| 105 | //------------------------------------------------- |
| 106 | // sound_stream_update - handle a stream update |
| 107 | //------------------------------------------------- |
| 108 | |
| 109 | void redbaron_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 79 | 110 | { |
| 80 | | redbaron_sound_state *state = get_safe_token(device); |
| 81 | 111 | stream_sample_t *buffer = outputs[0]; |
| 82 | 112 | while( samples-- ) |
| 83 | 113 | { |
| 84 | 114 | int sum = 0; |
| 85 | 115 | |
| 86 | 116 | /* polynome shifter E5 and F4 (LS164) clocked with 12kHz */ |
| 87 | | state->m_poly_counter -= 12000; |
| 88 | | while( state->m_poly_counter <= 0 ) |
| 117 | m_poly_counter -= 12000; |
| 118 | while( m_poly_counter <= 0 ) |
| 89 | 119 | { |
| 90 | | state->m_poly_counter += OUTPUT_RATE; |
| 91 | | if( ((state->m_poly_shift & 0x0001) == 0) == ((state->m_poly_shift & 0x4000) == 0) ) |
| 92 | | state->m_poly_shift = (state->m_poly_shift << 1) | 1; |
| 120 | m_poly_counter += OUTPUT_RATE; |
| 121 | if( ((m_poly_shift & 0x0001) == 0) == ((m_poly_shift & 0x4000) == 0) ) |
| 122 | m_poly_shift = (m_poly_shift << 1) | 1; |
| 93 | 123 | else |
| 94 | | state->m_poly_shift <<= 1; |
| 124 | m_poly_shift <<= 1; |
| 95 | 125 | } |
| 96 | 126 | |
| 97 | 127 | /* What is the exact low pass filter frequency? */ |
| 98 | | state->m_filter_counter -= 330; |
| 99 | | while( state->m_filter_counter <= 0 ) |
| 128 | m_filter_counter -= 330; |
| 129 | while( m_filter_counter <= 0 ) |
| 100 | 130 | { |
| 101 | | state->m_filter_counter += OUTPUT_RATE; |
| 102 | | state->m_crash_amp = (state->m_poly_shift & 1) ? state->m_latch >> 4 : 0; |
| 131 | m_filter_counter += OUTPUT_RATE; |
| 132 | m_crash_amp = (m_poly_shift & 1) ? m_latch >> 4 : 0; |
| 103 | 133 | } |
| 104 | 134 | /* mix crash sound at 35% */ |
| 105 | | sum += state->m_vol_crash[state->m_crash_amp] * 35 / 100; |
| 135 | sum += m_vol_crash[m_crash_amp] * 35 / 100; |
| 106 | 136 | |
| 107 | 137 | /* shot not active: charge C32 (0.1u) */ |
| 108 | | if( (state->m_latch & 0x04) == 0 ) |
| 109 | | state->m_shot_amp = 32767; |
| 138 | if( (m_latch & 0x04) == 0 ) |
| 139 | m_shot_amp = 32767; |
| 110 | 140 | else |
| 111 | | if( (state->m_poly_shift & 0x8000) == 0 ) |
| 141 | if( (m_poly_shift & 0x8000) == 0 ) |
| 112 | 142 | { |
| 113 | | if( state->m_shot_amp > 0 ) |
| 143 | if( m_shot_amp > 0 ) |
| 114 | 144 | { |
| 115 | 145 | /* discharge C32 (0.1u) through R26 (33k) + R27 (15k) |
| 116 | 146 | * 0.68 * C32 * (R26 + R27) = 3264us |
| r21254 | r21255 | |
| 118 | 148 | // #define C32_DISCHARGE_TIME (int)(32767 / 0.003264); |
| 119 | 149 | /* I think this is to short. Is C32 really 1u? */ |
| 120 | 150 | #define C32_DISCHARGE_TIME (int)(32767 / 0.03264); |
| 121 | | state->m_shot_amp_counter -= C32_DISCHARGE_TIME; |
| 122 | | while( state->m_shot_amp_counter <= 0 ) |
| 151 | m_shot_amp_counter -= C32_DISCHARGE_TIME; |
| 152 | while( m_shot_amp_counter <= 0 ) |
| 123 | 153 | { |
| 124 | | state->m_shot_amp_counter += OUTPUT_RATE; |
| 125 | | if( --state->m_shot_amp == 0 ) |
| 154 | m_shot_amp_counter += OUTPUT_RATE; |
| 155 | if( --m_shot_amp == 0 ) |
| 126 | 156 | break; |
| 127 | 157 | } |
| 128 | 158 | /* mix shot sound at 35% */ |
| 129 | | sum += state->m_vol_lookup[state->m_shot_amp] * 35 / 100; |
| 159 | sum += m_vol_lookup[m_shot_amp] * 35 / 100; |
| 130 | 160 | } |
| 131 | 161 | } |
| 132 | 162 | |
| 133 | 163 | |
| 134 | | if( (state->m_latch & 0x02) == 0 ) |
| 135 | | state->m_squeal_amp = 0; |
| 164 | if( (m_latch & 0x02) == 0 ) |
| 165 | m_squeal_amp = 0; |
| 136 | 166 | else |
| 137 | 167 | { |
| 138 | | if( state->m_squeal_amp < 32767 ) |
| 168 | if( m_squeal_amp < 32767 ) |
| 139 | 169 | { |
| 140 | 170 | /* charge C5 (22u) over R3 (68k) and CR1 (1N914) |
| 141 | 171 | * time = 0.68 * C5 * R3 = 1017280us |
| 142 | 172 | */ |
| 143 | 173 | #define C5_CHARGE_TIME (int)(32767 / 1.01728); |
| 144 | | state->m_squeal_amp_counter -= C5_CHARGE_TIME; |
| 145 | | while( state->m_squeal_amp_counter <= 0 ) |
| 174 | m_squeal_amp_counter -= C5_CHARGE_TIME; |
| 175 | while( m_squeal_amp_counter <= 0 ) |
| 146 | 176 | { |
| 147 | | state->m_squeal_amp_counter += OUTPUT_RATE; |
| 148 | | if( ++state->m_squeal_amp == 32767 ) |
| 177 | m_squeal_amp_counter += OUTPUT_RATE; |
| 178 | if( ++m_squeal_amp == 32767 ) |
| 149 | 179 | break; |
| 150 | 180 | } |
| 151 | 181 | } |
| 152 | 182 | |
| 153 | | if( state->m_squeal_out ) |
| 183 | if( m_squeal_out ) |
| 154 | 184 | { |
| 155 | 185 | /* NE555 setup as pulse position modulator |
| 156 | 186 | * C = 0.01u, Ra = 33k, Rb = 47k |
| 157 | 187 | * frequency = 1.44 / ((33k + 2*47k) * 0.01u) = 1134Hz |
| 158 | 188 | * modulated by squeal_amp |
| 159 | 189 | */ |
| 160 | | state->m_squeal_off_counter -= (1134 + 1134 * state->m_squeal_amp / 32767) / 3; |
| 161 | | while( state->m_squeal_off_counter <= 0 ) |
| 190 | m_squeal_off_counter -= (1134 + 1134 * m_squeal_amp / 32767) / 3; |
| 191 | while( m_squeal_off_counter <= 0 ) |
| 162 | 192 | { |
| 163 | | state->m_squeal_off_counter += OUTPUT_RATE; |
| 164 | | state->m_squeal_out = 0; |
| 193 | m_squeal_off_counter += OUTPUT_RATE; |
| 194 | m_squeal_out = 0; |
| 165 | 195 | } |
| 166 | 196 | } |
| 167 | 197 | else |
| 168 | 198 | { |
| 169 | | state->m_squeal_on_counter -= 1134; |
| 170 | | while( state->m_squeal_on_counter <= 0 ) |
| 199 | m_squeal_on_counter -= 1134; |
| 200 | while( m_squeal_on_counter <= 0 ) |
| 171 | 201 | { |
| 172 | | state->m_squeal_on_counter += OUTPUT_RATE; |
| 173 | | state->m_squeal_out = 1; |
| 202 | m_squeal_on_counter += OUTPUT_RATE; |
| 203 | m_squeal_out = 1; |
| 174 | 204 | } |
| 175 | 205 | } |
| 176 | 206 | } |
| 177 | 207 | |
| 178 | 208 | /* mix sequal sound at 40% */ |
| 179 | | if( state->m_squeal_out ) |
| 209 | if( m_squeal_out ) |
| 180 | 210 | sum += 32767 * 40 / 100; |
| 181 | 211 | |
| 182 | 212 | *buffer++ = sum; |
| 183 | 213 | } |
| 184 | 214 | } |
| 185 | 215 | |
| 186 | | static DEVICE_START( redbaron_sound ) |
| 187 | | { |
| 188 | | redbaron_sound_state *state = get_safe_token(device); |
| 189 | | int i; |
| 190 | 216 | |
| 191 | | state->m_vol_lookup = auto_alloc_array(device->machine(), INT16, 32768); |
| 192 | | for( i = 0; i < 0x8000; i++ ) |
| 193 | | state->m_vol_lookup[0x7fff-i] = (INT16) (0x7fff/exp(1.0*i/4096)); |
| 194 | | |
| 195 | | for( i = 0; i < 16; i++ ) |
| 196 | | { |
| 197 | | /* r0 = R18 and R24, r1 = open */ |
| 198 | | double r0 = 1.0/(5600 + 680), r1 = 1/6e12; |
| 199 | | |
| 200 | | /* R14 */ |
| 201 | | if( i & 1 ) |
| 202 | | r1 += 1.0/8200; |
| 203 | | else |
| 204 | | r0 += 1.0/8200; |
| 205 | | /* R15 */ |
| 206 | | if( i & 2 ) |
| 207 | | r1 += 1.0/3900; |
| 208 | | else |
| 209 | | r0 += 1.0/3900; |
| 210 | | /* R16 */ |
| 211 | | if( i & 4 ) |
| 212 | | r1 += 1.0/2200; |
| 213 | | else |
| 214 | | r0 += 1.0/2200; |
| 215 | | /* R17 */ |
| 216 | | if( i & 8 ) |
| 217 | | r1 += 1.0/1000; |
| 218 | | else |
| 219 | | r0 += 1.0/1000; |
| 220 | | r0 = 1.0/r0; |
| 221 | | r1 = 1.0/r1; |
| 222 | | state->m_vol_crash[i] = 32767 * r0 / (r0 + r1); |
| 223 | | } |
| 224 | | |
| 225 | | state->m_channel = device->machine().sound().stream_alloc(*device, 0, 1, OUTPUT_RATE, 0, redbaron_sound_update); |
| 226 | | } |
| 227 | | |
| 228 | | const device_type REDBARON = &device_creator<redbaron_sound_device>; |
| 229 | | |
| 230 | | redbaron_sound_device::redbaron_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 231 | | : device_t(mconfig, REDBARON, "Red Baron Custom", tag, owner, clock), |
| 232 | | device_sound_interface(mconfig, *this) |
| 217 | WRITE8_MEMBER( redbaron_sound_device::redbaron_sounds_w ) |
| 233 | 218 | { |
| 234 | | m_token = global_alloc_clear(redbaron_sound_state); |
| 235 | | } |
| 219 | /* If sound is off, don't bother playing samples */ |
| 220 | if( data == m_latch ) |
| 221 | return; |
| 236 | 222 | |
| 237 | | //------------------------------------------------- |
| 238 | | // device_config_complete - perform any |
| 239 | | // operations now that the configuration is |
| 240 | | // complete |
| 241 | | //------------------------------------------------- |
| 242 | | |
| 243 | | void redbaron_sound_device::device_config_complete() |
| 244 | | { |
| 223 | m_channel->update(); |
| 224 | m_latch = data; |
| 245 | 225 | } |
| 246 | 226 | |
| 247 | | //------------------------------------------------- |
| 248 | | // device_start - device-specific startup |
| 249 | | //------------------------------------------------- |
| 250 | 227 | |
| 251 | | void redbaron_sound_device::device_start() |
| 228 | #ifdef UNUSED_FUNCTION |
| 229 | WRITE8_MEMBER( redbaron_sound_device::redbaron_pokey_w ) |
| 252 | 230 | { |
| 253 | | DEVICE_START_NAME( redbaron_sound )(this); |
| 231 | if( m_latch & 0x20 ) |
| 232 | pokey_w(device, offset, data); |
| 254 | 233 | } |
| 255 | | |
| 256 | | //------------------------------------------------- |
| 257 | | // sound_stream_update - handle a stream update |
| 258 | | //------------------------------------------------- |
| 259 | | |
| 260 | | void redbaron_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 261 | | { |
| 262 | | // should never get here |
| 263 | | fatalerror("sound_stream_update called; not applicable to legacy sound devices\n"); |
| 264 | | } |
| 234 | #endif |