trunk/src/emu/sound/es5503.c
| r17705 | r17706 | |
| 32 | 32 | 0.5 (RB) - more flexible wave memory hookup (incl. banking) and save state support. |
| 33 | 33 | 1.0 (RB) - properly respects the input clock |
| 34 | 34 | 2.0 (RB) - C++ conversion, more accurate oscillator IRQ timing |
| 35 | 2.1 (RB) - Corrected phase when looping; synthLAB, Arkanoid, and Arkanoid II no longer go out of tune |
| 35 | 36 | */ |
| 36 | 37 | |
| 37 | 38 | #include "emu.h" |
| r17705 | r17706 | |
| 109 | 110 | // chip = chip ptr |
| 110 | 111 | // onum = oscillator # |
| 111 | 112 | // type = 1 for 0 found in sample data, 0 for hit end of table size |
| 112 | | void es5503_device::halt_osc(int onum, int type, UINT32 *accumulator) |
| 113 | void es5503_device::halt_osc(int onum, int type, UINT32 *accumulator, int resshift) |
| 113 | 114 | { |
| 114 | 115 | ES5503Osc *pOsc = &oscillators[onum]; |
| 115 | 116 | ES5503Osc *pPartner = &oscillators[onum^1]; |
| r17705 | r17706 | |
| 120 | 121 | { |
| 121 | 122 | pOsc->control |= 1; |
| 122 | 123 | } |
| 123 | | else |
| 124 | else // preserve the relative phase of the oscillator when looping. I think. |
| 124 | 125 | { |
| 125 | | // reset the accumulator if not halting |
| 126 | | *accumulator = 0; |
| 126 | UINT16 wtsize = pOsc->wtsize - 1; |
| 127 | UINT32 altram = (*accumulator) >> resshift; |
| 128 | |
| 129 | if (altram > wtsize) |
| 130 | { |
| 131 | altram -= wtsize; |
| 132 | } |
| 133 | else |
| 134 | { |
| 135 | altram = 0; |
| 136 | } |
| 137 | |
| 138 | *accumulator = altram << resshift; |
| 127 | 139 | } |
| 128 | 140 | |
| 129 | 141 | // if swap mode, start the partner |
| r17705 | r17706 | |
| 175 | 187 | |
| 176 | 188 | for (snum = 0; snum < samples; snum++) |
| 177 | 189 | { |
| 178 | | ramptr = (acc >> resshift) & sizemask; |
| 179 | 190 | altram = acc >> resshift; |
| 191 | ramptr = altram & sizemask; |
| 180 | 192 | |
| 181 | 193 | acc += freq; |
| 182 | 194 | |
| r17705 | r17706 | |
| 186 | 198 | |
| 187 | 199 | if (m_direct->read_raw_byte(ramptr + wtptr) == 0x00) |
| 188 | 200 | { |
| 189 | | halt_osc(osc, 1, &acc); |
| 201 | halt_osc(osc, 1, &acc, resshift); |
| 190 | 202 | } |
| 191 | 203 | else |
| 192 | 204 | { |
| r17705 | r17706 | |
| 203 | 215 | |
| 204 | 216 | if (altram >= wtsize) |
| 205 | 217 | { |
| 206 | | halt_osc(osc, 0, &acc); |
| 218 | halt_osc(osc, 0, &acc, resshift); |
| 207 | 219 | } |
| 208 | 220 | } |
| 209 | 221 | |