[Gambatte] HuC3 improvements

This commit is contained in:
CasualPokePlayer 2022-03-27 15:22:34 -07:00
parent 848ff87be1
commit e206c3287b
6 changed files with 36 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View File

@ -124,9 +124,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
if (IsSgb)
{
ProcessSgbSound((int)samplesEmittedInFrame, (rendersound && !Muted));
ProcessSgbSound((int)samplesEmittedInFrame, rendersound && !Muted);
}
ProcessMbcSound(rendersound && !Muted);
if (rendersound && !Muted)
{
ProcessSoundEnd();

View File

@ -39,6 +39,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
// sample pairs before resampling
private readonly short[] _soundbuff = new short[(35112 + 2064) * 2];
private readonly short[] _sgbsoundbuff = new short[2048 * 2];
private readonly short[] _mbcsoundbuff = new short[(35112 + 2064) * 2];
private int _soundoutbuffcontains = 0;
@ -50,6 +51,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
private int _sgbLatchL = 0;
private int _sgbLatchR = 0;
private int _mbcLatchL = 0;
private int _mbcLatchR = 0;
private BlipBuffer _blipL, _blipR;
private uint _blipAccumulate;
@ -104,6 +108,31 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
}
}
private void ProcessMbcSound(bool processSound)
{
int nsamp = LibGambatte.gambatte_generatembcsamples(GambatteState, _mbcsoundbuff);
if (nsamp == 0)
{
return;
}
for (uint i = 0; i < nsamp; i++)
{
int ls = _mbcsoundbuff[i * 2] - _mbcLatchL;
int rs = _mbcsoundbuff[(i * 2) + 1] - _mbcLatchR;
if (ls != 0 && processSound)
{
_blipL.AddDelta(i, ls);
}
if (rs != 0 && processSound)
{
_blipR.AddDelta(i, rs);
}
_mbcLatchL = _mbcsoundbuff[i * 2];
_mbcLatchR = _mbcsoundbuff[(i * 2) + 1];
}
}
private void ProcessSoundEnd()
{
_blipL.EndFrame(_blipAccumulate);

View File

@ -100,6 +100,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
public static extern int gambatte_generatesgbsamples(IntPtr core, short[] soundbuf, out uint samples);
[DllImport("libgambatte", CallingConvention = CallingConvention.Cdecl)]
public static extern int gambatte_generatembcsamples(IntPtr core, short[] soundbuf);
/// <summary>
/// Reset to initial state.
/// Equivalent to reloading a ROM image, or turning a Game Boy Color off and on again.

@ -1 +1 @@
Subproject commit 098d085fc432de2f88846398c6a2771283f25b34
Subproject commit a89db5c3e68aed4a79645a12f9ae9b1fc1e9d980