add 'bool rendersound' to IEmualtor.FrameAdvance()

if false, the emulator is free to gain whatever speedup it can by not doing audio processing (shouldn't change anything sync related, though)
the core should still always call SoundProvider.GetSamples() after each FrameAdvance(), else DRAGONS
at the moment, only test-implemented in gambattehawk
This commit is contained in:
goyuken 2012-09-20 19:52:47 +00:00
parent 1301344d71
commit 51fc8e695c
13 changed files with 28 additions and 20 deletions

View File

@ -152,7 +152,7 @@ namespace BizHawk
}
public void FrameAdvance(bool render)
public void FrameAdvance(bool render, bool rendersound)
{
_frame++;
_islag = true;

View File

@ -419,7 +419,7 @@ namespace BizHawk.Emulation.Consoles.Calculator
//configuration
ushort startPC;
public void FrameAdvance(bool render)
public void FrameAdvance(bool render, bool rendersound)
{
lagged = true;
//I eyeballed this speed

View File

@ -55,7 +55,7 @@ namespace BizHawk.Emulation.Consoles.Coleco
cpu.WriteMemory = WriteMemory;
}
public void FrameAdvance(bool render)
public void FrameAdvance(bool render, bool rendersound)
{
_frame++;
_islag = true;

View File

@ -70,7 +70,7 @@ namespace BizHawk.Emulation.Consoles.Intellivision
Cpu.LogData();
}
public void FrameAdvance(bool render)
public void FrameAdvance(bool render, bool rendersound)
{
Frame++;
Cpu.AddPendingCycles(14394 + 3791);

View File

@ -94,7 +94,7 @@ namespace BizHawk.Emulation.Consoles.GB
return (LibGambatte.gambatte_iscgb(GambatteState));
}
public void FrameAdvance(bool render)
public void FrameAdvance(bool render, bool rendersound)
{
uint nsamp = 35112; // according to gambatte docs, this is the nominal length of a frame in 2mhz clocks
@ -137,7 +137,10 @@ namespace BizHawk.Emulation.Consoles.GB
foreach (var r in MemoryRefreshers)
r.RefreshRead();
soundbuffcontains = (int)nsamp;
if (rendersound)
soundbuffcontains = (int)nsamp;
else
soundbuffcontains = 0;
if (IsLagFrame)
LagCount++;
@ -516,10 +519,13 @@ namespace BizHawk.Emulation.Consoles.GB
public void GetSamples(short[] samples)
{
resampler.EnqueueSamples(soundbuff, soundbuffcontains);
soundbuffcontains = 0;
resampler.Flush();
metaspu.GetSamples(samples);
if (soundbuffcontains > 0)
{
resampler.EnqueueSamples(soundbuff, soundbuffcontains);
soundbuffcontains = 0;
resampler.Flush();
metaspu.GetSamples(samples);
}
}
public void DiscardSamples()

View File

@ -68,7 +68,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
}
bool resetSignal;
public void FrameAdvance(bool render)
public void FrameAdvance(bool render, bool rendersound)
{
videoProvider.FillFrameBuffer();

View File

@ -306,7 +306,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
}
}
public void FrameAdvance(bool render)
public void FrameAdvance(bool render, bool rendersound)
{
bool resetSignal = Controller["Reset"];
if (resetSignal) LibsnesDll.snes_reset();

View File

@ -232,7 +232,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
Frame = 0;
}
public void FrameAdvance(bool render)
public void FrameAdvance(bool render, bool rendersound)
{
lagged = true;
Controller.UpdateControls(Frame++);

View File

@ -139,7 +139,7 @@ namespace BizHawk.Emulation.Consoles.Sega
InitializeSaveRam(game);
}
public void FrameAdvance(bool render)
public void FrameAdvance(bool render, bool rendersound)
{
lagged = true;

View File

@ -189,7 +189,7 @@ namespace BizHawk.Emulation.Consoles.Sega
}
}
public void FrameAdvance(bool render)
public void FrameAdvance(bool render, bool rendersound)
{
lagged = true;
Controller.UpdateControls(Frame++);

View File

@ -28,7 +28,7 @@ namespace BizHawk
Frame = 0;
}
public void FrameAdvance(bool render)
public void FrameAdvance(bool render, bool rendersound)
{
if (render == false) return;
for (int i = 0; i < 256 * 192; i++)

View File

@ -12,7 +12,9 @@ namespace BizHawk
ControllerDefinition ControllerDefinition { get; }
IController Controller { get; set; }
void FrameAdvance(bool render);
// note that most cores expect you to call SoundProvider.GetSamples() after each FrameAdvance()
// please do this, even when rendersound = false
void FrameAdvance(bool render, bool rendersound);
int Frame { get; }
int LagCount { get; set; }

View File

@ -1999,7 +1999,7 @@ namespace BizHawk.MultiClient
if (Global.Config.SkipLagFrame && Global.Emulator.IsLagFrame && frameProgressTimeElapsed)
{
Global.Emulator.FrameAdvance(true);
Global.Emulator.FrameAdvance(true, true);
}
if (Global.ClientControls["Frame Advance"] || PressFrameAdvance)
@ -2116,7 +2116,7 @@ namespace BizHawk.MultiClient
//=======================================
MemoryPulse.Pulse();
Global.Emulator.FrameAdvance(!throttle.skipnextframe);
Global.Emulator.FrameAdvance(!throttle.skipnextframe, true);
MemoryPulse.Pulse();
//=======================================
if (CurrAviWriter != null)
@ -3278,7 +3278,7 @@ namespace BizHawk.MultiClient
for (int j = 0; j < frameskip; j++)
{
StepRunLoop_Core();
Global.Emulator.FrameAdvance(true); //Frame advance
Global.Emulator.FrameAdvance(true, true); //Frame advance
//Global.RenderPanel.Render(Global.Emulator.VideoProvider);
if (gifSpeed > 0)