Previous 199869 Revisions Next

r17706 Saturday 8th September, 2012 at 01:31:25 UTC by R. Belmont
es5503: Preserve phase when oscillators loop [R. Belmont]
[src/emu/sound]es5503.c es5503.h

trunk/src/emu/sound/es5503.c
r17705r17706
3232  0.5 (RB) - more flexible wave memory hookup (incl. banking) and save state support.
3333  1.0 (RB) - properly respects the input clock
3434  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
3536*/
3637
3738#include "emu.h"
r17705r17706
109110// chip = chip ptr
110111// onum = oscillator #
111112// type = 1 for 0 found in sample data, 0 for hit end of table size
112void es5503_device::halt_osc(int onum, int type, UINT32 *accumulator)
113void es5503_device::halt_osc(int onum, int type, UINT32 *accumulator, int resshift)
113114{
114115   ES5503Osc *pOsc = &oscillators[onum];
115116   ES5503Osc *pPartner = &oscillators[onum^1];
r17705r17706
120121   {
121122      pOsc->control |= 1;
122123   }
123   else
124   else    // preserve the relative phase of the oscillator when looping.  I think.
124125   {
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;
127139   }
128140
129141   // if swap mode, start the partner
r17705r17706
175187
176188         for (snum = 0; snum < samples; snum++)
177189         {
178            ramptr = (acc >> resshift) & sizemask;
179190            altram = acc >> resshift;
191            ramptr = altram & sizemask;
180192
181193            acc += freq;
182194
r17705r17706
186198
187199            if (m_direct->read_raw_byte(ramptr + wtptr) == 0x00)
188200            {
189               halt_osc(osc, 1, &acc);
201               halt_osc(osc, 1, &acc, resshift);
190202            }
191203            else
192204            {
r17705r17706
203215
204216               if (altram >= wtsize)
205217               {
206                  halt_osc(osc, 0, &acc);
218                  halt_osc(osc, 0, &acc, resshift);
207219               }
208220            }
209221
trunk/src/emu/sound/es5503.h
r17705r17706
9595
9696    direct_read_data *m_direct;
9797
98    void halt_osc(int onum, int type, UINT32 *accumulator);
98    void halt_osc(int onum, int type, UINT32 *accumulator, int resshift);
9999};
100100
101101

Previous 199869 Revisions Next


© 1997-2024 The MAME Team