trunk/src/emu/sound/es5503.c
| r17874 | r17875 | |
| 1 | 1 | /* |
| 2 | 2 | |
| 3 | | ES5503 - Ensoniq ES5503 "DOC" emulator v1. |
| 3 | ES5503 - Ensoniq ES5503 "DOC" emulator v2.1.1 |
| 4 | 4 | By R. Belmont. |
| 5 | 5 | |
| 6 | 6 | Copyright R. Belmont. |
| r17874 | r17875 | |
| 33 | 33 | 1.0 (RB) - properly respects the input clock |
| 34 | 34 | 2.0 (RB) - C++ conversion, more accurate oscillator IRQ timing |
| 35 | 35 | 2.1 (RB) - Corrected phase when looping; synthLAB, Arkanoid, and Arkanoid II no longer go out of tune |
| 36 | 2.1.1 (RB) - Fixed issue introduced in 2.0 where IRQs were delayed |
| 36 | 37 | */ |
| 37 | 38 | |
| 38 | 39 | #include "emu.h" |
| r17874 | r17875 | |
| 117 | 118 | int mode = (pOsc->control>>1) & 3; |
| 118 | 119 | |
| 119 | 120 | // if 0 found in sample data or mode is not free-run, halt this oscillator |
| 120 | | if ((type != MODE_FREE) || (mode > 0)) |
| 121 | if ((mode != MODE_FREE) || (type != 0)) |
| 121 | 122 | { |
| 122 | 123 | pOsc->control |= 1; |
| 123 | 124 | } |
| 124 | | else // preserve the relative phase of the oscillator when looping. I think. |
| 125 | else // preserve the relative phase of the oscillator when looping |
| 125 | 126 | { |
| 126 | 127 | UINT16 wtsize = pOsc->wtsize - 1; |
| 127 | 128 | UINT32 altram = (*accumulator) >> resshift; |
| r17874 | r17875 | |
| 142 | 143 | if (mode == MODE_SWAP) |
| 143 | 144 | { |
| 144 | 145 | pPartner->control &= ~1; // clear the halt bit |
| 145 | | pPartner->accumulator = 0; // and make sure it starts from the top |
| 146 | pPartner->accumulator = 0; // and make sure it starts from the top (does this also need phase preservation?) |
| 146 | 147 | } |
| 147 | 148 | |
| 148 | 149 | // IRQ enabled for this voice? |
| r17874 | r17875 | |
| 249 | 250 | // find our direct access |
| 250 | 251 | m_direct = &space()->direct(); |
| 251 | 252 | |
| 252 | | rege0 = 0x80; |
| 253 | rege0 = 0xff; |
| 253 | 254 | |
| 254 | 255 | for (osc = 0; osc < 32; osc++) |
| 255 | 256 | { |
| r17874 | r17875 | |
| 269 | 270 | m_stream = machine().sound().stream_alloc(*this, 0, 2, output_rate, this); |
| 270 | 271 | |
| 271 | 272 | m_timer = timer_alloc(0, NULL); |
| 272 | | m_timer->adjust(attotime::from_hz(output_rate)); |
| 273 | m_timer->adjust(attotime::from_hz(output_rate), 0, attotime::from_hz(output_rate)); |
| 273 | 274 | } |
| 274 | 275 | |
| 275 | 276 | void es5503_device::device_reset() |
| 276 | 277 | { |
| 277 | | rege0 = 0x80; |
| 278 | rege0 = 0xff; |
| 278 | 279 | |
| 279 | 280 | for (int osc = 0; osc < 32; osc++) |
| 280 | 281 | { |
| r17874 | r17875 | |
| 344 | 345 | { |
| 345 | 346 | switch (offset) |
| 346 | 347 | { |
| 347 | | case 0xe0: // interrupt status |
| 348 | case 0xe0: // interrupt status |
| 348 | 349 | retval = rege0; |
| 349 | 350 | |
| 351 | if (m_irq_func) |
| 352 | { |
| 353 | m_irq_func(this, 0); |
| 354 | } |
| 355 | |
| 350 | 356 | // scan all oscillators |
| 351 | 357 | for (i = 0; i < oscsenabled+1; i++) |
| 352 | 358 | { |
| r17874 | r17875 | |
| 358 | 364 | rege0 = retval | 0x80; |
| 359 | 365 | |
| 360 | 366 | // and clear its flag |
| 361 | | oscillators[i].irqpend--; |
| 362 | | |
| 363 | | if (m_irq_func) |
| 364 | | { |
| 365 | | m_irq_func(this, 0); |
| 366 | | } |
| 367 | oscillators[i].irqpend = 0; |
| 367 | 368 | break; |
| 368 | 369 | } |
| 369 | 370 | } |
| r17874 | r17875 | |
| 467 | 468 | |
| 468 | 469 | output_rate = (clock()/8)/(2+oscsenabled); |
| 469 | 470 | m_stream->set_sample_rate(output_rate); |
| 470 | | m_timer->adjust(attotime::from_hz(output_rate)); |
| 471 | m_timer->adjust(attotime::from_hz(output_rate), 0, attotime::from_hz(output_rate)); |
| 471 | 472 | break; |
| 472 | 473 | |
| 473 | 474 | case 0xe2: // A/D converter |