PsfPlayer: Added frame counting to PspVm.

git-svn-id: http://svn.purei.org/purei/trunk@632 b36208d7-6611-0410-8bec-b1987f11c4a2
This commit is contained in:
jpd002 2010-04-29 04:06:34 +00:00
parent bec29e19d2
commit 3565761a04
2 changed files with 15 additions and 0 deletions

View File

@ -2,6 +2,8 @@
using namespace Psp;
#define SAMPLES_PER_FRAME (44100 / 60)
CPsfSubSystem::CPsfSubSystem(uint32 ramSize)
: m_ram(new uint8[ramSize])
, m_ramSize(ramSize)
@ -47,6 +49,8 @@ void CPsfSubSystem::Reset()
m_bios.GetSasCore()->SetSpuInfo(&m_spuCore0, &m_spuCore1, m_spuRam, SPURAMSIZE);
m_bios.GetAudio()->SetStream(&m_audioStream);
m_samplesToFrame = SAMPLES_PER_FRAME;
}
CMIPS& CPsfSubSystem::GetCpu()
@ -113,6 +117,16 @@ void CPsfSubSystem::Update(bool singleStep, CSoundHandler* soundHandler)
{
soundHandler->Write(buffer, bufferSamples, 44100);
}
m_samplesToFrame -= (bufferSamples / 2);
if(m_samplesToFrame <= 0)
{
m_samplesToFrame += SAMPLES_PER_FRAME;
if(!OnNewFrame.empty())
{
OnNewFrame();
}
}
}
}
#endif

View File

@ -59,6 +59,7 @@ namespace Psp
Iop::CSpuBase m_spuCore0;
Iop::CSpuBase m_spuCore1;
Framework::CMemStream m_audioStream;
int m_samplesToFrame;
Psp::CPsfBios m_bios;
};