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),
m_CRC(_CRC),
m_NumSyncMail(0),
m_bSyncInProgress(false),
m_MaxVoice(0),
@ -188,14 +190,18 @@ void CUCode_Zelda::HandleMail_LightVersion(u32 _uMail)
void CUCode_Zelda::HandleMail_SMSVersion(u32 _uMail)
{
if (m_bSyncCmdPending)
{
if (m_bSyncInProgress)
{
m_bSyncInProgress = false;
if (m_bSyncCmdPending)
{
m_SyncFlags[(m_NumSyncMail << 1) ] = _uMail >> 16;
m_SyncFlags[(m_NumSyncMail << 1) + 1] = _uMail & 0xFFFF;
m_SyncFlags[2] = _uMail >> 16;
m_SyncFlags[3] = _uMail & 0xFFFF;
m_NumSyncMail++;
if (m_NumSyncMail == 2)
{
m_NumSyncMail = 0;
m_bSyncInProgress = false;
m_CurBuffer++;
@ -215,12 +221,10 @@ void CUCode_Zelda::HandleMail_SMSVersion(u32 _uMail)
m_bSyncCmdPending = false;
}
}
}
else
{
m_bSyncInProgress = true;
m_SyncFlags[0] = _uMail >> 16;
m_SyncFlags[1] = _uMail & 0xFFFF;
m_bSyncInProgress = false;
}
return;
@ -245,6 +249,11 @@ void CUCode_Zelda::HandleMail_SMSVersion(u32 _uMail)
// Here holds: m_bSyncInProgress == false && m_bListInProgress == false
if (_uMail == 0)
{
m_bSyncInProgress = true;
m_NumSyncMail = 0;
}
if ((_uMail >> 16) == 0)
{
m_bListInProgress = true;
@ -553,6 +562,8 @@ void CUCode_Zelda::DoState(PointerWrap &p)
p.Do(m_MaxVoice);
p.Do(m_SyncFlags);
p.Do(m_NumSyncMail);
p.Do(m_NumVoices);
p.Do(m_bSyncCmdPending);

View File

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