From 966349aeb4b0d0ba5d9e9fe5b64673fb2db72786 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 20 Oct 2012 15:19:06 +1100 Subject: [PATCH] changed how linking to enter section --- .../N64 System/Recompiler/Code Block.cpp | 57 +++++++++++++++++-- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/Source/Project64/N64 System/Recompiler/Code Block.cpp b/Source/Project64/N64 System/Recompiler/Code Block.cpp index 8be39f26c..a2b8d9cab 100644 --- a/Source/Project64/N64 System/Recompiler/Code Block.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Block.cpp @@ -8,13 +8,30 @@ CCodeBlock::CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos) : m_VAddrLast(VAddrEnter), m_CompiledLocation(RecompPos), m_Test(1), - m_EnterSection(new CCodeSection(this, VAddrEnter, 1, false)) + m_EnterSection(NULL) { - if (m_EnterSection) + CCodeSection * baseSection = new CCodeSection(this, VAddrEnter, 0, false); + if (baseSection == NULL) { - m_EnterSection->AddParent(NULL); - m_Sections.push_back(m_EnterSection); + _Notify->BreakPoint(__FILE__,__LINE__); } + m_Sections.push_back(baseSection); + baseSection->AddParent(NULL); + baseSection->m_CompiledLocation = (BYTE *)-1; + baseSection->m_Cont.JumpPC = VAddrEnter; + baseSection->m_Cont.FallThrough = true; + baseSection->m_Cont.RegSet = baseSection->m_RegEnter; + + m_EnterSection = new CCodeSection(this, VAddrEnter, 1, true); + if (m_EnterSection == NULL) + { + _Notify->BreakPoint(__FILE__,__LINE__); + } + baseSection->m_ContinueSection = m_EnterSection; + + m_EnterSection->AddParent(baseSection); + m_Sections.push_back(m_EnterSection); + m_SectionMap.insert(SectionMap::value_type(VAddrEnter,m_EnterSection)); if (_TransVaddr->VAddrToRealAddr(VAddrEnter,*(reinterpret_cast(&m_MemLocation[0])))) { @@ -85,7 +102,7 @@ bool CCodeBlock::SetSection ( CCodeSection * & Section, CCodeSection * CurrentSe Section->AddParent(CurrentSection); if (TargetPC < CurrentPC && TargetPC != m_VAddrEnter) { - CCodeSection * SplitSection = m_EnterSection; + CCodeSection * SplitSection = NULL; for (SectionMap::const_iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++) { if (itr->first >= TargetPC) @@ -94,6 +111,10 @@ bool CCodeBlock::SetSection ( CCodeSection * & Section, CCodeSection * CurrentSe } SplitSection = itr->second; } + if (SplitSection == NULL) + { + _Notify->BreakPoint(__FILE__,__LINE__); + } if (SplitSection->m_EndPC == (DWORD)-1) { _Notify->BreakPoint(__FILE__,__LINE__); @@ -145,6 +166,26 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection ) } CurrentSection->m_EndPC = TestPC - 4; CurrentSection = itr->second; + + //section changed find first unprocessed section + /*for (SectionMap::iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++) + { + CCodeSection * Section = itr->second; + if (Section->m_JumpSection != NULL || + Section->m_ContinueSection != NULL || + Section->m_EndSection) + { + continue; + } + if (CurrentSection != Section) + { + CPU_Message("- Section %d",CurrentSection->m_SectionID); + CurrentSection = Section; + } + break; + }*/ + + CPU_Message("Section %d",CurrentSection->m_SectionID); if (EnterSection != m_EnterSection) { @@ -269,7 +310,7 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection ) //retest current section if we added a section if (SectionCount != m_Sections.size()) { - CCodeSection * NewSection = m_EnterSection; + CCodeSection * NewSection = NULL; for (SectionMap::const_iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++) { if (itr->first > TestPC) @@ -278,6 +319,10 @@ bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection ) } NewSection = itr->second; } + if (NewSection == NULL) + { + _Notify->BreakPoint(__FILE__,__LINE__); + } if (CurrentSection == NewSection) { _Notify->BreakPoint(__FILE__,__LINE__);