Previous 199869 Revisions Next

r32476 Wednesday 1st October, 2014 at 05:10:26 UTC by Alex Jackson
k053260: delta PCM decoding rolls over instead of clipping; fixes MT#1007 [Alex Jackson]
[src/emu/sound]k053260.c

trunk/src/emu/sound/k053260.c
r32475r32476
128128
129129void k053260_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
130130{
131   static const long dpcmcnv[] = { 0,1,2,4,8,16,32,64, -128, -64, -32, -16, -8, -4, -2, -1};
131   static const INT8 dpcmcnv[] = { 0,1,2,4,8,16,32,64, -128, -64, -32, -16, -8, -4, -2, -1};
132132
133   int i, j, lvol[4], rvol[4], play[4], loop[4], ppcm_data[4], ppcm[4];
134   unsigned char *rom[4];
133   int lvol[4], rvol[4], play[4], loop[4], ppcm[4];
134   UINT8 *rom[4];
135135   UINT32 delta[4], end[4], pos[4];
136   INT8 ppcm_data[4];
136137   int dataL, dataR;
137   signed char d;
138   INT8 d;
138139
139140   /* precache some values */
140   for ( i = 0; i < 4; i++ ) {
141   for ( int i = 0; i < 4; i++ ) {
141142      rom[i]= &m_rom[m_channels[i].start + ( m_channels[i].bank << 16 )];
142143      delta[i] = m_delta_table[m_channels[i].rate];
143144      lvol[i] = m_channels[i].volume * m_channels[i].pan;
r32475r32476
152153         delta[i] /= 2;
153154   }
154155
155      for ( j = 0; j < samples; j++ ) {
156      for ( int j = 0; j < samples; j++ ) {
156157         dataL = dataR = 0;
157158
158         for ( i = 0; i < 4; i++ ) {
159         for ( int i = 0; i < 4; i++ ) {
159160            /* see if the voice is on */
160161            if ( play[i] ) {
161162               /* see if we're done */
r32475r32476
183184                        newdata = ( ( rom[i][pos[i] >> BASE_SHIFT] ) ) & 0x0f; /*low nybble*/
184185                     }
185186
186                     ppcm_data[i] = (( ( ppcm_data[i] * 62 ) >> 6 ) + dpcmcnv[newdata]);
187
188                     if ( ppcm_data[i] > 127 )
189                        ppcm_data[i] = 127;
190                     else
191                        if ( ppcm_data[i] < -128 )
192                           ppcm_data[i] = -128;
187                     ppcm_data[i] += dpcmcnv[newdata];
193188                  }
194189
195190
r32475r32476
215210      }
216211
217212   /* update the regs now */
218   for ( i = 0; i < 4; i++ ) {
213   for ( int i = 0; i < 4; i++ ) {
219214      m_channels[i].pos = pos[i];
220215      m_channels[i].play = play[i];
221216      m_channels[i].ppcm_data = ppcm_data[i];

Previous 199869 Revisions Next


© 1997-2024 The MAME Team