Fixed MSM6376 distorted playback.

Added sample ROM to newmcard.
This commit is contained in:
Phil Bennett 2009-01-12 17:10:29 +00:00
parent bd0d0269ff
commit 7ffb225922
2 changed files with 44 additions and 38 deletions

View File

@ -172,24 +172,41 @@ static void generate_adpcm(struct okim6376 *chip, struct ADPCMVoice *voice, INT1
/* loop while we still have samples to generate */ /* loop while we still have samples to generate */
while (samples) while (samples)
{ {
/* compute the new amplitude and update the current step */ int nibble;
int nibble = base[sample / 2] >> (((sample & 1) << 2) ^ 4);
/* output to the buffer, scaling by the volume */ if (count == 0)
/* signal in range -4096..4095, volume in range 2..16 => signal * volume / 2 in range -32768..32767 */ {
*buffer++ = clock_adpcm(voice, nibble) * voice->volume / 2; /* get the number of samples to play */
samples--; count = (base[sample / 2] & 0x7f) << 1;
/* next! */ /* end of voice marker */
if (++sample >= count) if (count == 0)
{ {
voice->playing = 0; voice->playing = 0;
break; break;
} }
else
{
/* step past the count byte */
sample += 2;
}
}
/* compute the new amplitude and update the current step */
nibble = base[sample / 2] >> (((sample & 1) << 2) ^ 4);
/* output to the buffer, scaling by the volume */
/* signal in range -4096..4095, volume in range 2..16 => signal * volume / 2 in range -32768..32767 */
*buffer++ = clock_adpcm(voice, nibble) * voice->volume / 2;
++sample;
--count;
--samples;
} }
/* update the parameters */ /* update the parameters */
voice->sample = sample; voice->sample = sample;
voice->count = count;
} }
/* fill the rest with silence */ /* fill the rest with silence */
@ -365,7 +382,7 @@ static void okim6376_data_w(int num, int data)
/* if a command is pending, process the second half */ /* if a command is pending, process the second half */
if (info->command != -1) if (info->command != -1)
{ {
int temp = data >> 4, i, start, stop; int temp = data >> 4, i, start;
unsigned char *base, *base_end; unsigned char *base, *base_end;
@ -383,28 +400,24 @@ static void okim6376_data_w(int num, int data)
{ {
struct ADPCMVoice *voice = &info->voice[i]; struct ADPCMVoice *voice = &info->voice[i];
/* determine the start/stop positions, max address space is 16Mbit */ /* determine the start position, max address space is 16Mbit */
base = &info->region_base[info->command * 4]; base = &info->region_base[info->command * 4];
base_end = &info->region_base[(MAX_WORDS+1) * 4]; base_end = &info->region_base[(MAX_WORDS+1) * 4];
start = ((base[0] << 16) + (base[1] << 8) + base[2]) & 0x1fffff; start = ((base[0] << 16) + (base[1] << 8) + base[2]) & 0x1fffff;
if (start == 0) {
voice->playing = 0;
} else {
/* FIX: for now handle stop reading the next sample start */
do {
stop = ((base[4] << 16) + (base[5] << 8) + base[6]) & 0x1fffff;
if (stop == 0) base += 4;
} while (stop == 0 && base < base_end);
/* set up the voice to play this sample */ if (start == 0)
if (start < stop)
{ {
voice->playing = 0;
}
else
{
/* set up the voice to play this sample */
if (!voice->playing) if (!voice->playing)
{ {
voice->playing = 1; voice->playing = 1;
voice->base_offset = start; voice->base_offset = start;
voice->sample = 0; voice->sample = 0;
voice->count = 2 * (stop - start + 1); voice->count = 0;
/* also reset the ADPCM parameters */ /* also reset the ADPCM parameters */
reset_adpcm(voice); reset_adpcm(voice);
@ -416,13 +429,6 @@ static void okim6376_data_w(int num, int data)
logerror("OKIM6376:%d requested to play sample %02x on non-stopped voice\n",num,info->command); logerror("OKIM6376:%d requested to play sample %02x on non-stopped voice\n",num,info->command);
} }
} }
/* invalid samples go here */
else
{
logerror("OKIM6376:%d requested to play invalid sample %02x\n",num,info->command);
voice->playing = 0;
}
}
} }
} }

View File

@ -667,7 +667,7 @@ ROM_START( newmcard )
ROM_COPY( "user1", 0x0c0000, 0x000000, 0x40000 ) ROM_COPY( "user1", 0x0c0000, 0x000000, 0x40000 )
ROM_REGION( 0x080000, "samples", 0 ) /* M6376 Samples */ ROM_REGION( 0x080000, "samples", 0 ) /* M6376 Samples */
ROM_LOAD( "mc33.ic5", 0x00000, 0x80000, CRC(83a855ab) SHA1(7f9384c875b951d17caa91f8a7365edaf7f9afe1) ) ROM_LOAD( "mc31.ic15", 0x00000, 0x40000, CRC(8b72ffec) SHA1(fca5cf2594325e0c9fe446ddf2330c669f7f37a9) )
ROM_END ROM_END
/* /*