diff --git a/Source/Project64-core/N64System/Mips/GBCart.cpp b/Source/Project64-core/N64System/Mips/GBCart.cpp index b73d955e2..1dc729930 100644 --- a/Source/Project64-core/N64System/Mips/GBCart.cpp +++ b/Source/Project64-core/N64System/Mips/GBCart.cpp @@ -294,7 +294,7 @@ static void read_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, uint8_t { if (gb_cart->ram != NULL) { - if (gb_cart->ram_bank >= 0x00 && gb_cart->ram_bank <= 0x03) + if (gb_cart->ram_bank <= 0x03) { offset = (address - 0xA000) + (gb_cart->ram_bank * 0x2000); if (offset < gb_cart->ram_size) @@ -373,7 +373,7 @@ static void write_gb_cart_mbc3(struct gb_cart* gb_cart, uint16_t address, const { if (gb_cart->ram != NULL) { - if (gb_cart->ram_bank >= 0x00 && gb_cart->ram_bank <= 0x03) + if (gb_cart->ram_bank <= 0x03) { offset = (address - 0xA000) + (gb_cart->ram_bank * 0x2000); if (offset < gb_cart->ram_size) diff --git a/Source/Project64-core/N64System/N64Class.cpp b/Source/Project64-core/N64System/N64Class.cpp index 49043c527..53b9f9a50 100644 --- a/Source/Project64-core/N64System/N64Class.cpp +++ b/Source/Project64-core/N64System/N64Class.cpp @@ -889,6 +889,14 @@ void CN64System::InitRegisters(bool bPostPif, CMipsMemoryVM & MMU) m_Reg.m_GPR[5].DW = 0xFFFFFFFFE067221F; m_Reg.m_GPR[14].DW = 0x000000005CD2B70F; break; + case CIC_NUS_6101: + case CIC_NUS_6104: + case CIC_NUS_5167: + case CIC_NUS_8303: + case CIC_NUS_DDUS: + default: + //no specific values + break; } m_Reg.m_GPR[20].DW = 0x0000000000000001; m_Reg.m_GPR[23].DW = 0x0000000000000000; diff --git a/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp b/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp index b0c7aa7dc..aa47b77dc 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp +++ b/Source/Project64-core/N64System/Recompiler/CodeBlock.cpp @@ -181,8 +181,14 @@ bool CCodeBlock::SetSection(CCodeSection * & Section, CCodeSection * CurrentSect BaseSection->m_JumpSection = SplitSection->m_JumpSection; BaseSection->SetContinueAddress(SplitSection->m_Cont.JumpPC, SplitSection->m_Cont.TargetPC); BaseSection->m_ContinueSection = SplitSection->m_ContinueSection; - BaseSection->m_JumpSection->SwitchParent(SplitSection, BaseSection); - BaseSection->m_ContinueSection->SwitchParent(SplitSection, BaseSection); + if (BaseSection->m_JumpSection) + { + BaseSection->m_JumpSection->SwitchParent(SplitSection, BaseSection); + } + if (BaseSection->m_ContinueSection) + { + BaseSection->m_ContinueSection->SwitchParent(SplitSection, BaseSection); + } BaseSection->AddParent(SplitSection); SplitSection->m_EndPC = TargetPC - 4; @@ -400,7 +406,10 @@ void CCodeBlock::DetermineLoops() CCodeSection * Section = itr->second; uint32_t Test = NextTest(); - Section->DetermineLoop(Test, Test, Section->m_SectionID); + if (Section) + { + Section->DetermineLoop(Test, Test, Section->m_SectionID); + } } } @@ -750,11 +759,11 @@ bool CCodeBlock::Compile() m_RecompilerOps->EnterCodeBlock(); if (g_System->bLinkBlocks()) { - while (m_EnterSection->GenerateNativeCode(NextTest())); + while (m_EnterSection !=NULL && m_EnterSection->GenerateNativeCode(NextTest())); } else { - if (!m_EnterSection->GenerateNativeCode(NextTest())) + if (m_EnterSection == NULL || !m_EnterSection->GenerateNativeCode(NextTest())) { return false; } diff --git a/Source/Project64-core/N64System/Recompiler/CodeSection.cpp b/Source/Project64-core/N64System/Recompiler/CodeSection.cpp index 311f8e925..f44d13031 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeSection.cpp +++ b/Source/Project64-core/N64System/Recompiler/CodeSection.cpp @@ -341,7 +341,7 @@ void CCodeSection::GenerateSectionLinkage() for (i = 0; i < 2; i++) { - if (JumpInfo[i]->FallThrough && !TargetSection[i]->GenerateNativeCode(m_BlockInfo->NextTest())) + if (JumpInfo[i]->FallThrough && (TargetSection[i] == NULL || !TargetSection[i]->GenerateNativeCode(m_BlockInfo->NextTest()))) { JumpInfo[i]->FallThrough = false; m_RecompilerOps->JumpToUnknown(JumpInfo[i]); @@ -441,8 +441,6 @@ bool CCodeSection::ParentContinue() bool CCodeSection::GenerateNativeCode(uint32_t Test) { - if (this == NULL) { return false; } - if (m_CompiledLocation != NULL) { if (m_Test == Test) @@ -450,8 +448,8 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) return false; } m_Test = Test; - if (m_ContinueSection->GenerateNativeCode(Test)) { return true; } - if (m_JumpSection->GenerateNativeCode(Test)) { return true; } + if (m_ContinueSection != NULL && m_ContinueSection->GenerateNativeCode(Test)) { return true; } + if (m_JumpSection != NULL && m_JumpSection->GenerateNativeCode(Test)) { return true; } return false; } @@ -766,6 +764,14 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) m_RecompilerOps->GetRegWorkingSet().SetBlockCycleCount(m_RecompilerOps->GetRegWorkingSet().GetBlockCycleCount() - g_System->CountPerOp()); m_RecompilerOps->SetCurrentPC(m_RecompilerOps->GetCurrentPC() - 4); break; + case JUMP: + case END_BLOCK: + // Do nothing, block will end + break; + default: + CPU_Message("m_RecompilerOps->GetNextStepType() = %d", m_RecompilerOps->GetNextStepType()); + g_Notify->BreakPoint(__FILE__, __LINE__); + break; } if (m_DelaySlot) @@ -802,7 +808,6 @@ bool CCodeSection::GenerateNativeCode(uint32_t Test) void CCodeSection::AddParent(CCodeSection * Parent) { - if (this == NULL) { return; } if (Parent == NULL) { m_RecompilerOps->SetRegWorkingSet(m_RegEnter); @@ -850,8 +855,6 @@ void CCodeSection::AddParent(CCodeSection * Parent) void CCodeSection::SwitchParent(CCodeSection * OldParent, CCodeSection * NewParent) { - if (this == NULL) { return; } - bool bFoundOldParent = false; for (SECTION_LIST::iterator iter = m_ParentSection.begin(); iter != m_ParentSection.end(); iter++) { @@ -901,15 +904,19 @@ void CCodeSection::TestRegConstantStates(CRegInfo & Base, CRegInfo & Reg) void CCodeSection::DetermineLoop(uint32_t Test, uint32_t Test2, uint32_t TestID) { - if (this == NULL) { return; } - if (m_SectionID == TestID) { if (m_Test2 != Test2) { m_Test2 = Test2; - m_ContinueSection->DetermineLoop(Test, Test2, TestID); - m_JumpSection->DetermineLoop(Test, Test2, TestID); + if (m_ContinueSection) + { + m_ContinueSection->DetermineLoop(Test, Test2, TestID); + } + if (m_JumpSection) + { + m_JumpSection->DetermineLoop(Test, Test2, TestID); + } if (m_Test != Test) { @@ -934,15 +941,20 @@ void CCodeSection::DetermineLoop(uint32_t Test, uint32_t Test2, uint32_t TestID) if (m_Test2 != Test2) { m_Test2 = Test2; - m_ContinueSection->DetermineLoop(Test, Test2, TestID); - m_JumpSection->DetermineLoop(Test, Test2, TestID); + if (m_ContinueSection) + { + m_ContinueSection->DetermineLoop(Test, Test2, TestID); + } + if (m_JumpSection) + { + m_JumpSection->DetermineLoop(Test, Test2, TestID); + } } } } CCodeSection * CCodeSection::ExistingSection(uint32_t Addr, uint32_t Test) { - if (this == NULL) { return NULL; } if (m_EnterPC == Addr && m_LinkAllowed) { return this; @@ -950,9 +962,9 @@ CCodeSection * CCodeSection::ExistingSection(uint32_t Addr, uint32_t Test) if (m_Test == Test) { return NULL; } m_Test = Test; - CCodeSection * Section = m_JumpSection->ExistingSection(Addr, Test); + CCodeSection * Section = m_JumpSection ? m_JumpSection->ExistingSection(Addr, Test) : NULL; if (Section != NULL) { return Section; } - Section = m_ContinueSection->ExistingSection(Addr, Test); + Section = m_ContinueSection ? m_ContinueSection->ExistingSection(Addr, Test) : NULL; if (Section != NULL) { return Section; } return NULL; @@ -960,7 +972,6 @@ CCodeSection * CCodeSection::ExistingSection(uint32_t Addr, uint32_t Test) bool CCodeSection::SectionAccessible(uint32_t SectionId, uint32_t Test) { - if (this == NULL) { return false; } if (m_SectionID == SectionId) { return true; @@ -969,20 +980,15 @@ bool CCodeSection::SectionAccessible(uint32_t SectionId, uint32_t Test) if (m_Test == Test) { return false; } m_Test = Test; - if (m_ContinueSection->SectionAccessible(SectionId, Test)) + if (m_ContinueSection && m_ContinueSection->SectionAccessible(SectionId, Test)) { return true; } - return m_JumpSection->SectionAccessible(SectionId, Test); + return m_JumpSection && m_JumpSection->SectionAccessible(SectionId, Test); } void CCodeSection::UnlinkParent(CCodeSection * Parent, bool ContinueSection) { - if (this == NULL) - { - return; - } - CPU_Message("%s: Section %d Parent: %d ContinueSection = %s", __FUNCTION__, m_SectionID, Parent->m_SectionID, ContinueSection ? "Yes" : "No"); if (Parent->m_ContinueSection == this && Parent->m_JumpSection == this) { @@ -1084,13 +1090,12 @@ bool CCodeSection::DisplaySectionInformation(uint32_t ID, uint32_t Test) { return false; } - if (this == NULL) { return false; } if (m_Test == Test) { return false; } m_Test = Test; if (m_SectionID != ID) { - if (m_ContinueSection->DisplaySectionInformation(ID, Test)) { return true; } - if (m_JumpSection->DisplaySectionInformation(ID, Test)) { return true; } + if (m_ContinueSection != NULL && m_ContinueSection->DisplaySectionInformation(ID, Test)) { return true; } + if (m_JumpSection != NULL && m_JumpSection->DisplaySectionInformation(ID, Test)) { return true; } return false; } DisplaySectionInformation(); diff --git a/Source/Project64-core/N64System/Recompiler/CodeSection.h b/Source/Project64-core/N64System/Recompiler/CodeSection.h index 1fe9d37ef..517b289e6 100644 --- a/Source/Project64-core/N64System/Recompiler/CodeSection.h +++ b/Source/Project64-core/N64System/Recompiler/CodeSection.h @@ -28,7 +28,6 @@ public: bool GenerateNativeCode(uint32_t Test); void GenerateSectionLinkage(); void DetermineLoop(uint32_t Test, uint32_t Test2, uint32_t TestID); - bool FixConstants(uint32_t Test); CCodeSection * ExistingSection(uint32_t Addr, uint32_t Test); bool SectionAccessible(uint32_t SectionId, uint32_t Test); bool DisplaySectionInformation(uint32_t ID, uint32_t Test); diff --git a/Source/Project64-core/N64System/Recompiler/LoopAnalysis.cpp b/Source/Project64-core/N64System/Recompiler/LoopAnalysis.cpp index 6378b0e8a..d25a4d5fa 100644 --- a/Source/Project64-core/N64System/Recompiler/LoopAnalysis.cpp +++ b/Source/Project64-core/N64System/Recompiler/LoopAnalysis.cpp @@ -745,7 +745,8 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) m_NextInstruction = END_BLOCK; SetJumpRegSet(Section, m_Reg); } - else { + else + { switch (m_NextInstruction) { case NORMAL: @@ -760,29 +761,17 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) } break; case LIKELY_DELAY_SLOT: - { SetContinueRegSet(Section, m_Reg); SetJumpRegSet(Section, m_Reg); - } - m_NextInstruction = END_BLOCK; - break; + m_NextInstruction = END_BLOCK; + break; case DELAY_SLOT_DONE: - { SetContinueRegSet(Section, m_Reg); SetJumpRegSet(Section, m_Reg); - } - m_NextInstruction = END_BLOCK; - break; + m_NextInstruction = END_BLOCK; + break; case LIKELY_DELAY_SLOT_DONE: g_Notify->BreakPoint(__FILE__, __LINE__); - if (Section->m_CompiledLocation) - { - } - else - { - //Section->m_Jump.RegSet = m_Reg; - //Section->m_Jump.DoneDelaySlot = true; - } m_NextInstruction = END_BLOCK; break; } @@ -1146,8 +1135,8 @@ void LoopAnalysis::SPECIAL_DADD() if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { m_Reg.SetMipsReg(m_Command.rd, - m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs) + - m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) + (m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) + + (m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt)) ); m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); } @@ -1167,8 +1156,8 @@ void LoopAnalysis::SPECIAL_DADDU() if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { m_Reg.SetMipsReg(m_Command.rd, - m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs) + - m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) + (m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) + + (m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt)) ); m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); } @@ -1188,8 +1177,8 @@ void LoopAnalysis::SPECIAL_DSUB() if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { m_Reg.SetMipsReg(m_Command.rd, - m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs) - - m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) + (m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) - + (m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt)) ); m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); } @@ -1209,8 +1198,8 @@ void LoopAnalysis::SPECIAL_DSUBU() if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { m_Reg.SetMipsReg(m_Command.rd, - m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs) - - m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) + (m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs)) - + (m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt)) ); m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); } diff --git a/Source/Project64-core/N64System/Recompiler/RecompilerClass.cpp b/Source/Project64-core/N64System/Recompiler/RecompilerClass.cpp index 6aea99fa1..546894729 100644 --- a/Source/Project64-core/N64System/Recompiler/RecompilerClass.cpp +++ b/Source/Project64-core/N64System/Recompiler/RecompilerClass.cpp @@ -167,174 +167,174 @@ void CRecompiler::RecompilerMain_VirtualTable() void CRecompiler::RecompilerMain_VirtualTable_validate() { g_Notify->BreakPoint(__FILE__, __LINE__); - /* PCCompiledFunc_TABLE * m_FunctionTable = m_Functions.GetFunctionTable(); +#ifdef legacycode + PCCompiledFunc_TABLE * m_FunctionTable = m_Functions.GetFunctionTable(); - while(!m_EndEmulation) + while (!m_EndEmulation) { - /*if (NextInstruction == DELAY_SLOT) - { - CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER); - //Find Block on hash table - if (Info == NULL) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - #ifdef legacycode - if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) - { - DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); - NextInstruction = NORMAL; - if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) - { - g_Notify->DisplayError("Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); - return; - } - continue; - } - #endif - //Find Block on hash table - Info = CompileDelaySlot(PROGRAM_COUNTER); + if (NextInstruction == DELAY_SLOT) + { + CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER); + //Find Block on hash table + if (Info == NULL) + { + g_Notify->BreakPoint(__FILE__, __LINE__); +#ifdef legacycode + if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) + { + DoTLBMiss(NextInstruction == DELAY_SLOT, PROGRAM_COUNTER); + NextInstruction = NORMAL; + if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) + { + g_Notify->DisplayError("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PROGRAM_COUNTER); + return; + } + continue; + } +#endif + //Find Block on hash table + Info = CompileDelaySlot(PROGRAM_COUNTER); - if (Info == NULL || EndEmulation()) - { - break; - } - } - const uint8_t * Block = Info->FunctionAddr(); - if ((*Info->MemLocation[0] != Info->MemContents[0]) || - (*Info->MemLocation[1] != Info->MemContents[1])) - { - ClearRecompCode_Virt((Info->VStartPC() - 0x1000) & ~0xFFF,0x2000,Remove_ValidateFunc); - NextInstruction = DELAY_SLOT; - Info = NULL; - continue; - } - _asm { - pushad - call Block - popad - } - continue; - }*/ - /* PCCompiledFunc_TABLE table = m_FunctionTable[PROGRAM_COUNTER >> 0xC]; - if (table) - { - CCompiledFunc * info = table[(PROGRAM_COUNTER & 0xFFF) >> 2]; - if (info != NULL) - { - if ((*info->MemLocation[0] != info->MemContents[0]) || - (*info->MemLocation[1] != info->MemContents[1])) - { - ClearRecompCode_Virt((info->VStartPC() - 0x1000) & ~0xFFF,0x3000,Remove_ValidateFunc); - info = NULL; - continue; - } - const uint8_t * Block = info->FunctionAddr(); - _asm { - pushad - call Block - popad - } - continue; - } - } - g_Notify->BreakPoint(__FILE__, __LINE__); - #ifdef legacycode - if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) - { - DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); - NextInstruction = NORMAL; - if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) - { - g_Notify->DisplayError("Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); - return; - } - } - #endif - CCompiledFunc * info = CompileCode(); + if (Info == NULL || EndEmulation()) + { + break; + } + } + const uint8_t * Block = Info->FunctionAddr(); + if ((*Info->MemLocation[0] != Info->MemContents[0]) || + (*Info->MemLocation[1] != Info->MemContents[1])) + { + ClearRecompCode_Virt((Info->VStartPC() - 0x1000) & ~0xFFF, 0x2000, Remove_ValidateFunc); + NextInstruction = DELAY_SLOT; + Info = NULL; + continue; + } + _asm { + pushad + call Block + popad + } + continue; + } + PCCompiledFunc_TABLE table = m_FunctionTable[PROGRAM_COUNTER >> 0xC]; + if (table) + { + CCompiledFunc * info = table[(PROGRAM_COUNTER & 0xFFF) >> 2]; + if (info != NULL) + { + if ((*info->MemLocation[0] != info->MemContents[0]) || + (*info->MemLocation[1] != info->MemContents[1])) + { + ClearRecompCode_Virt((info->VStartPC() - 0x1000) & ~0xFFF, 0x3000, Remove_ValidateFunc); + info = NULL; + continue; + } + const uint8_t * Block = info->FunctionAddr(); + _asm { + pushad + call Block + popad + } + continue; + } + } + g_Notify->BreakPoint(__FILE__, __LINE__); +#ifdef legacycode + if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) + { + DoTLBMiss(NextInstruction == DELAY_SLOT, PROGRAM_COUNTER); + NextInstruction = NORMAL; + if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) + { + g_Notify->DisplayError("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PROGRAM_COUNTER); + return; + } + } +#endif + CCompiledFunc * info = CompileCode(); - if (info == NULL || EndEmulation()) - { - break; - } + if (info == NULL || EndEmulation()) + { + break; + } } - /* - while(!m_EndEmulation) + while (!m_EndEmulation) { - if (!g_MMU->ValidVaddr(PROGRAM_COUNTER)) - { - DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); - NextInstruction = NORMAL; - if (!g_MMU->ValidVaddr(PROGRAM_COUNTER)) - { - g_Notify->DisplayError("Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); - return; - } - } - if (NextInstruction == DELAY_SLOT) - { - CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER); + if (!g_MMU->ValidVaddr(PROGRAM_COUNTER)) + { + DoTLBMiss(NextInstruction == DELAY_SLOT, PROGRAM_COUNTER); + NextInstruction = NORMAL; + if (!g_MMU->ValidVaddr(PROGRAM_COUNTER)) + { + g_Notify->DisplayError("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PROGRAM_COUNTER); + return; + } + } + if (NextInstruction == DELAY_SLOT) + { + CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER); - //Find Block on hash table - if (Info == NULL) - { - Info = CompileDelaySlot(PROGRAM_COUNTER); + //Find Block on hash table + if (Info == NULL) + { + Info = CompileDelaySlot(PROGRAM_COUNTER); - if (Info == NULL || EndEmulation()) - { - break; - } - } - if (bSMM_ValidFunc()) - { - if ((*Info->MemLocation[0] != Info->MemContents[0]) || - (*Info->MemLocation[1] != Info->MemContents[1])) - { - ClearRecompCode_Virt((Info->StartPC() - 0x1000) & ~0xFFF,0x2000,Remove_ValidateFunc); - NextInstruction = DELAY_SLOT; - Info = NULL; - continue; - } - } - const uint8_t * Block = Info->FunctionAddr(); - _asm { - pushad - call Block - popad - } - continue; - } + if (Info == NULL || EndEmulation()) + { + break; + } + } + if (bSMM_ValidFunc()) + { + if ((*Info->MemLocation[0] != Info->MemContents[0]) || + (*Info->MemLocation[1] != Info->MemContents[1])) + { + ClearRecompCode_Virt((Info->StartPC() - 0x1000) & ~0xFFF, 0x2000, Remove_ValidateFunc); + NextInstruction = DELAY_SLOT; + Info = NULL; + continue; + } + } + const uint8_t * Block = Info->FunctionAddr(); + _asm { + pushad + call Block + popad + } + continue; + } - CCompiledFunc * Info = m_Functions.FindFunction(PROGRAM_COUNTER); + CCompiledFunc * Info = m_Functions.FindFunction(PROGRAM_COUNTER); - //Find Block on hash table - if (Info == NULL) - { - Info = CompileCode(); + //Find Block on hash table + if (Info == NULL) + { + Info = CompileCode(); - if (Info == NULL || EndEmulation()) - { - break; + if (Info == NULL || EndEmulation()) + { + break; + } + } + if (bSMM_ValidFunc()) + { + if ((*Info->MemLocation[0] != Info->MemContents[0]) || + (*Info->MemLocation[1] != Info->MemContents[1])) + { + ClearRecompCode_Virt((Info->StartPC() - 0x1000) & ~0xFFF, 0x3000, Remove_ValidateFunc); + Info = NULL; + continue; + } + } + const uint8_t * Block = Info->FunctionAddr(); + _asm { + pushad + call Block + popad + } } - } - if (bSMM_ValidFunc()) - { - if ((*Info->MemLocation[0] != Info->MemContents[0]) || - (*Info->MemLocation[1] != Info->MemContents[1])) - { - ClearRecompCode_Virt((Info->StartPC() - 0x1000) & ~0xFFF,0x3000,Remove_ValidateFunc); - Info = NULL; - continue; - } - } - const uint8_t * Block = Info->FunctionAddr(); - _asm { - pushad - call Block - popad - } - } - */ +#endif } void CRecompiler::RecompilerMain_Lookup() @@ -384,7 +384,7 @@ void CRecompiler::RecompilerMain_Lookup() while(!m_EndEmulation) { - /*if (bUseTlb()) + if (bUseTlb()) { g_Notify->BreakPoint(__FILE__, __LINE__); #ifdef legacycode @@ -511,14 +511,14 @@ void CRecompiler::RecompilerMain_Lookup() sprintf(Label,"PC: %X to %X",ProfAddress,ProfAddress+ 0xFFC); // StartTimer(Label); } - /*if (PROGRAM_COUNTER >= 0x800DD000 && PROGRAM_COUNTER <= 0x800DDFFC) { + if (PROGRAM_COUNTER >= 0x800DD000 && PROGRAM_COUNTER <= 0x800DDFFC) { char Label[100]; sprintf(Label,"PC: %X Block: %X",PROGRAM_COUNTER,Block); StartTimer(Label); - }*/ + } // } else if ((Profiling || ShowCPUPer) && ProfilingLabel[0] == 0) { // StartTimer("r4300i Running"); - /* } + } #endif const uint8_t * Block = Info->FunctionAddr(); _asm { diff --git a/Source/Project64-core/N64System/Recompiler/SectionInfo.cpp b/Source/Project64-core/N64System/Recompiler/SectionInfo.cpp index b7ac3111e..7b2958533 100644 --- a/Source/Project64-core/N64System/Recompiler/SectionInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/SectionInfo.cpp @@ -47,11 +47,6 @@ bool CCodeSection::IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled void CCodeSection::UnlinkParent( CCodeSection * Parent, bool AllowDelete, bool ContinueSection ) { - if (this == NULL) - { - return; - } - SECTION_LIST::iterator iter = ParentSection.begin(); while ( iter != ParentSection.end()) { diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp index 0ea4485a5..12261a5a9 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp @@ -8336,12 +8336,12 @@ void CX86RecompilerOps::COP1_S_CMP() if ((m_Opcode.funct & 1) != 0) { - x86Reg Reg2 = Map_TempReg(x86_Any8Bit, 0, false); + x86Reg _86RegReg2 = Map_TempReg(x86_Any8Bit, 0, false); AndConstToX86Reg(x86_EAX, 0x4300); CompConstToX86reg(x86_EAX, 0x4300); - Setz(Reg2); + Setz(_86RegReg2); - OrX86RegToX86Reg(Reg, Reg2); + OrX86RegToX86Reg(Reg, _86RegReg2); } } else if ((m_Opcode.funct & 1) != 0) @@ -8709,12 +8709,12 @@ void CX86RecompilerOps::COP1_D_CMP() if ((m_Opcode.funct & 1) != 0) { - x86Reg Reg2 = Map_TempReg(x86_Any8Bit, 0, false); + x86Reg _86RegReg2 = Map_TempReg(x86_Any8Bit, 0, false); AndConstToX86Reg(x86_EAX, 0x4300); CompConstToX86reg(x86_EAX, 0x4300); - Setz(Reg2); + Setz(_86RegReg2); - OrX86RegToX86Reg(Reg, Reg2); + OrX86RegToX86Reg(Reg, _86RegReg2); } } else if ((m_Opcode.funct & 1) != 0) diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h index f1933deba..b19729b4f 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include @@ -27,9 +27,8 @@ class CCodeSection; class CX86RecompilerOps : public CRecompilerOps, - protected CDebugSettings, + protected R4300iOp, protected CX86Ops, - protected CSystemRegisters, protected CN64SystemSettings, protected CRecompilerSettings { diff --git a/Source/Project64-core/N64System/SpeedLimiterClass.cpp b/Source/Project64-core/N64System/SpeedLimiterClass.cpp index 44ad876ab..0442ea262 100644 --- a/Source/Project64-core/N64System/SpeedLimiterClass.cpp +++ b/Source/Project64-core/N64System/SpeedLimiterClass.cpp @@ -94,7 +94,7 @@ void CSpeedLimiter::AlterSpeed( const ESpeedChange SpeedChange ) { m_Speed += 5 * SpeedFactor; } - else if (m_Speed > 1 && SpeedChange == DECREASE_SPEED || SpeedChange == INCREASE_SPEED) + else if ((m_Speed > 1 && SpeedChange == DECREASE_SPEED) || SpeedChange == INCREASE_SPEED) { m_Speed += 1 * SpeedFactor; } diff --git a/Source/Project64-core/Plugins/PluginClass.cpp b/Source/Project64-core/Plugins/PluginClass.cpp index a5324bb97..06bdd1f06 100644 --- a/Source/Project64-core/Plugins/PluginClass.cpp +++ b/Source/Project64-core/Plugins/PluginClass.cpp @@ -422,6 +422,9 @@ void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) } m_Control->DllConfig(hParent); break; + case PLUGIN_TYPE_NONE: + default: + g_Notify->BreakPoint(__FILE__, __LINE__); } } diff --git a/Source/Project64-core/RomList/RomList.cpp b/Source/Project64-core/RomList/RomList.cpp index 1edb29a7d..33e274d1c 100644 --- a/Source/Project64-core/RomList/RomList.cpp +++ b/Source/Project64-core/RomList/RomList.cpp @@ -206,16 +206,16 @@ void CRomList::FillRomList(strlist & FileList, const char * Directory) SectionName.ToLower(); WriteTrace(TraceUserInterface, TraceDebug, "4 %s", SectionName.c_str()); - for (int32_t i = 0; i < ZipFile.NumFiles(); i++) + for (int32_t zi = 0; zi < ZipFile.NumFiles(); zi++) { - CSzFileItem * f = ZipFile.FileItem(i); + CSzFileItem * f = ZipFile.FileItem(zi); if (f->IsDir) { continue; } ROM_INFO RomInfo; - std::wstring FileNameW = ZipFile.FileNameIndex(i); + std::wstring FileNameW = ZipFile.FileNameIndex(zi); if (FileNameW.length() == 0) { continue; diff --git a/Source/Project64-core/Settings/SettingsClass.cpp b/Source/Project64-core/Settings/SettingsClass.cpp index 7f9b64c27..c2e0d7bd7 100644 --- a/Source/Project64-core/Settings/SettingsClass.cpp +++ b/Source/Project64-core/Settings/SettingsClass.cpp @@ -603,10 +603,10 @@ void CSettings::RegisterSetting(CSettings * _this, SettingID ID, SettingID Defau } else { - SettingID RdbSetting = (SettingID)_this->m_NextAutoSettingId; + SettingID AutoRdbSetting = (SettingID)_this->m_NextAutoSettingId; _this->m_NextAutoSettingId += 1; - _this->AddHandler(RdbSetting, new CSettingTypeRomDatabaseSetting(Category, DefaultStr, DefaultID, true)); - _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, RdbSetting)); + _this->AddHandler(AutoRdbSetting, new CSettingTypeRomDatabaseSetting(Category, DefaultStr, DefaultID, true)); + _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, AutoRdbSetting)); } break; default: @@ -1247,10 +1247,10 @@ void CSettings::UnregisterChangeCB(SettingID Type, void * Data, SettingChangedFu { if (item->Next) { - SettingID Type = Callback->first; + SettingID CallbackType = Callback->first; SETTING_CHANGED_CB * Next = item->Next; m_Callback.erase(Callback); - m_Callback.insert(SETTING_CALLBACK::value_type(Type, Next)); + m_Callback.insert(SETTING_CALLBACK::value_type(CallbackType, Next)); } else { diff --git a/Source/Project64/UserInterface/NotificationClass.cpp b/Source/Project64/UserInterface/NotificationClass.cpp index c04b21087..2ea0996c5 100644 --- a/Source/Project64/UserInterface/NotificationClass.cpp +++ b/Source/Project64/UserInterface/NotificationClass.cpp @@ -3,8 +3,8 @@ CNotificationImp & Notify(void) { - static CNotificationImp g_Notify; - return g_Notify; + static CNotificationImp Notify; + return Notify; } CNotificationImp::CNotificationImp() : @@ -56,8 +56,6 @@ void CNotificationImp::DisplayError(LanguageStringID StringID) const void CNotificationImp::DisplayError(const char * Message) const { - if (this == NULL) { return; } - WriteTrace(TraceUserInterface, TraceError, Message); WindowMode(); @@ -119,8 +117,6 @@ void CNotificationImp::DisplayMessage2(const char * Message) const bool CNotificationImp::AskYesNoQuestion(const char * Question) const { - if (this == NULL) { return false; } - WriteTrace(TraceUserInterface, TraceError, Question); WindowMode(); diff --git a/Source/Settings/Settings.cpp b/Source/Settings/Settings.cpp index ac447a153..7b35b9b4c 100644 --- a/Source/Settings/Settings.cpp +++ b/Source/Settings/Settings.cpp @@ -148,6 +148,11 @@ void RegisterSetting(short SettingID, SETTING_DATA_TYPE Type, const char * Name, case Data_String_RDB_Setting: Location = SettingType_RdbSetting; break; + case Data_DWORD_General: + case Data_String_General: + default: + Location = (SettingLocation)g_PluginSettings.DefaultLocation; + break; } switch (Type) @@ -215,6 +220,11 @@ void RegisterSetting2(short SettingID, SETTING_DATA_TYPE Type, const char * Name case Data_String_RDB_Setting: Location = SettingType_RdbSetting; break; + case Data_DWORD_General: + case Data_String_General: + default: + Location = (SettingLocation)g_PluginSettings.DefaultLocation; + break; } switch (Type)