Closed GoogleCodeExporter closed 8 years ago
I was totally wrong about the volume thing. Still not sure what it is, though.
It's
weird: When I run the pre-built Gens9j executable (441kb) it has crackling, but
when
I download the Gens9j source and built it, it does not have crackling (using
the same
Gens.cfg file both times, of course). Maybe one of the Gens version numbers at
http://www.bluetoaster.net/emu/all.htm is incorrect.
Original comment by nitsuja-@hotmail.com
on 27 Jul 2008 at 10:46
The cause was a defective ASM -> C code port
int i;
for (length--, i = 0; length > 0; length--, i++)
{
Buf_L[i] += (CD_Audio_Buffer_L[CD_Audio_Buffer_Read_Pos] * CDDAVol) >> 8;
Buf_R[i] += (CD_Audio_Buffer_R[CD_Audio_Buffer_Read_Pos] * CDDAVol) >> 8;
CD_Audio_Buffer_Read_Pos++;
CD_Audio_Buffer_Read_Pos &= 0xFFF;
}
is appearantly not equivalent to
int i = 0;
for (; i <= _length; i++)
{
CD_Audio_Buffer_L[(CD_Audio_Buffer_Read_Pos + i) & 0xFFF] >>= 8;
CD_Audio_Buffer_R[(CD_Audio_Buffer_Read_Pos + i) & 0xFFF] >>= 8;
CD_Audio_Buffer_L[(CD_Audio_Buffer_Read_Pos + i) & 0xFFF] *= CDDAVol;
CD_Audio_Buffer_R[(CD_Audio_Buffer_Read_Pos + i) & 0xFFF] *= CDDAVol;
}
__asm
{
mov ecx, _length
mov esi, CD_Audio_Buffer_Read_Pos
mov edi, Buf_L
dec ecx
loop_L:
mov eax, CD_Audio_Buffer_L[esi * 4]
add [edi], eax
inc esi
add edi, 4
and esi, 0xFFF
dec ecx
jns short loop_L
mov ecx, _length
mov esi, CD_Audio_Buffer_Read_Pos
mov edi, Buf_R
dec ecx
loop_R:
mov eax, CD_Audio_Buffer_R[esi * 4]
add [edi], eax
inc esi
add edi, 4
and esi, 0xFFF
dec ecx
jns short loop_R
mov CD_Audio_Buffer_Read_Pos, esi
}
Original comment by Upth...@gmail.com
on 27 Jul 2008 at 12:04
Your fix caused another problem, a fuzzy static sound in the background of
almost
everything. The problem was, you lose information if you shift right before
multiplying by the volume. I don't think that shifting right after multiplying
can
cause clipping issues in this case, unless the volume value is much higher than
256
(which it isn't allowed to be), so I changed it back to multiply then shift.
Original comment by nitsuja-@hotmail.com
on 27 Jul 2008 at 7:40
Original issue reported on code.google.com by
nitsuja-@hotmail.com
on 27 Jul 2008 at 6:26