Zelda uCode (SMS): fix a bug where we would receive more sync mails that expected.

Actually the sync mail sequences contain 3 mails, not 2.
That's what happens when you don't look at the uCode enough...

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3824 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
luigi2us 2009-07-17 23:26:21 +00:00
parent d5c7105c78
commit 8cdae6fc1d
2 changed files with 37 additions and 23 deletions

View File

@ -34,6 +34,8 @@ CUCode_Zelda::CUCode_Zelda(CMailHandler& _rMailHandler, u32 _CRC)
IUCode(_rMailHandler), IUCode(_rMailHandler),
m_CRC(_CRC), m_CRC(_CRC),
m_NumSyncMail(0),
m_bSyncInProgress(false), m_bSyncInProgress(false),
m_MaxVoice(0), m_MaxVoice(0),
@ -188,39 +190,41 @@ void CUCode_Zelda::HandleMail_LightVersion(u32 _uMail)
void CUCode_Zelda::HandleMail_SMSVersion(u32 _uMail) void CUCode_Zelda::HandleMail_SMSVersion(u32 _uMail)
{ {
if (m_bSyncCmdPending) if (m_bSyncInProgress)
{ {
if (m_bSyncInProgress) if (m_bSyncCmdPending)
{ {
m_bSyncInProgress = false; m_SyncFlags[(m_NumSyncMail << 1) ] = _uMail >> 16;
m_SyncFlags[(m_NumSyncMail << 1) + 1] = _uMail & 0xFFFF;
m_SyncFlags[2] = _uMail >> 16; m_NumSyncMail++;
m_SyncFlags[3] = _uMail & 0xFFFF; if (m_NumSyncMail == 2)
m_CurBuffer++;
m_rMailHandler.PushMail(DSP_SYNC);
g_dspInitialize.pGenerateDSPInterrupt();
m_rMailHandler.PushMail(0xF355FF00 | m_CurBuffer);
if (m_CurBuffer == m_NumBuffers)
{ {
m_rMailHandler.PushMail(DSP_FRAME_END); m_NumSyncMail = 0;
//g_dspInitialize.pGenerateDSPInterrupt(); m_bSyncInProgress = false;
soundStream->GetMixer()->SetHLEReady(true); m_CurBuffer++;
DEBUG_LOG(DSPHLE, "Update the SoundThread to be in sync");
soundStream->Update(); //do it in this thread to avoid sync problems
m_bSyncCmdPending = false; m_rMailHandler.PushMail(DSP_SYNC);
g_dspInitialize.pGenerateDSPInterrupt();
m_rMailHandler.PushMail(0xF355FF00 | m_CurBuffer);
if (m_CurBuffer == m_NumBuffers)
{
m_rMailHandler.PushMail(DSP_FRAME_END);
//g_dspInitialize.pGenerateDSPInterrupt();
soundStream->GetMixer()->SetHLEReady(true);
DEBUG_LOG(DSPHLE, "Update the SoundThread to be in sync");
soundStream->Update(); //do it in this thread to avoid sync problems
m_bSyncCmdPending = false;
}
} }
} }
else else
{ {
m_bSyncInProgress = true; m_bSyncInProgress = false;
m_SyncFlags[0] = _uMail >> 16;
m_SyncFlags[1] = _uMail & 0xFFFF;
} }
return; return;
@ -245,6 +249,11 @@ void CUCode_Zelda::HandleMail_SMSVersion(u32 _uMail)
// Here holds: m_bSyncInProgress == false && m_bListInProgress == false // Here holds: m_bSyncInProgress == false && m_bListInProgress == false
if (_uMail == 0)
{
m_bSyncInProgress = true;
m_NumSyncMail = 0;
}
if ((_uMail >> 16) == 0) if ((_uMail >> 16) == 0)
{ {
m_bListInProgress = true; m_bListInProgress = true;
@ -553,6 +562,8 @@ void CUCode_Zelda::DoState(PointerWrap &p)
p.Do(m_MaxVoice); p.Do(m_MaxVoice);
p.Do(m_SyncFlags); p.Do(m_SyncFlags);
p.Do(m_NumSyncMail);
p.Do(m_NumVoices); p.Do(m_NumVoices);
p.Do(m_bSyncCmdPending); p.Do(m_bSyncCmdPending);

View File

@ -242,6 +242,9 @@ private:
u32 m_MaxVoice; u32 m_MaxVoice;
u32 m_SyncFlags[16]; u32 m_SyncFlags[16];
// Used by SMS version
u32 m_NumSyncMail;
u32 m_NumVoices; u32 m_NumVoices;
bool m_bSyncCmdPending; bool m_bSyncCmdPending;