diff --git a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp index 78bb8102d..82b594d32 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp @@ -8,7 +8,7 @@ void ExecuteInterpreterOps (DWORD /*Cycles*/) _Notify->BreakPoint(__FILE__,__LINE__); } -int DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) { +bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) { OPCODE Command; if (!_MMU->LW_VAddr(PC + 4, Command.Hex)) { diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp index 83968f2b3..f14e0d4e5 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" //#include "../C Core/Logging.h" -int DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); +bool DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); #define ADDRESS_ERROR_EXCEPTION(Address,FromRead) \ _Reg->DoAddressError(m_NextInstruction == JUMP,Address,FromRead);\ diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp index 0f0bccd99..fe9ff3cdf 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp @@ -711,7 +711,7 @@ R4300iOp::Func * R4300iOp::BuildInterpreter (void ) return Jump_Opcode; } -int DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2); +bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2); void TestInterpreterJump (DWORD PC, DWORD TargetPC, int Reg1, int Reg2) { diff --git a/Source/Project64/N64 System/Recompiler/Code Block.cpp b/Source/Project64/N64 System/Recompiler/Code Block.cpp index 71ef7ea58..fd3b629f0 100644 --- a/Source/Project64/N64 System/Recompiler/Code Block.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Block.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -int DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2); +bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2); CCodeBlock::CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos) : m_VAddrEnter(VAddrEnter), diff --git a/Source/Project64/N64 System/Recompiler/Code Section.cpp b/Source/Project64/N64 System/Recompiler/Code Section.cpp index 1f47654d7..eee159055 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Section.cpp @@ -2,7 +2,7 @@ void InPermLoop ( void ); -int DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); +bool DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); int DelaySlotEffectsJump (DWORD JumpPC) { OPCODE Command; @@ -1472,6 +1472,7 @@ void CCodeSection::UnlinkParent( CCodeSection * Parent, bool ContinueSection ) return; } + CPU_Message(__FUNCTION__ ": Section %d Parent: %d ContinueSection = %s",m_SectionID,Parent->m_SectionID,ContinueSection?"Yes" :"No"); if (Parent->m_ContinueSection == this && Parent->m_JumpSection == this) { _Notify->BreakPoint(__FILE__,__LINE__); diff --git a/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp b/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp index e2fbe0a38..a4b559299 100644 --- a/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp +++ b/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp @@ -2,7 +2,7 @@ #define CHECKED_BUILD 1 -int DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); +bool DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); LoopAnalysis::LoopAnalysis(CCodeBlock * CodeBlock, CCodeSection * Section) : m_EnterSection(Section), @@ -413,7 +413,9 @@ bool LoopAnalysis::CheckLoopRegisterUsage( CCodeSection * Section) { _Notify->BreakPoint(__FILE__,__LINE__); } - if (Section->m_Jump.TargetPC != m_PC + ((short)m_Command.offset << 2) + 4) + if (Section->m_Jump.TargetPC != m_PC + ((short)m_Command.offset << 2) + 4 && + Section->m_JumpSection != NULL && + Section->m_Jump.TargetPC != (DWORD)-1) { _Notify->BreakPoint(__FILE__,__LINE__); } diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp index e74a58916..4d3057a19 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp @@ -21,13 +21,13 @@ void CRecompilerOps::CompileWriteTLBMiss (x86Reg AddressReg, x86Reg LookUpReg ) m_Section->CompileExit(m_CompilePC, m_CompilePC,m_RegWorkingSet,CExitInfo::TLBWriteMiss,FALSE,JeLabel32); } -int DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); +bool DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); /************************** Branch functions ************************/ void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc, BRANCH_TYPE BranchType, BOOL Link) { - static int EffectDelaySlot, DoneJumpDelay, DoneContinueDelay; static CRegInfo RegBeforeDelay; + static bool EffectDelaySlot; if ( m_NextInstruction == NORMAL ) { CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); @@ -1183,9 +1183,7 @@ void CRecompilerOps::BLTZ_Compare (void) { void CRecompilerOps::BGEZ_Compare (void) { if (IsConst(m_Opcode.rs)) { if (Is64Bit(m_Opcode.rs)) { -#ifndef EXTERNAL_RELEASE - _Notify->DisplayError("BGEZ 1"); -#endif + _Notify->BreakPoint(__FILE__,__LINE__); CRecompilerOps::UnknownOpcode(); } else if (IsSigned(m_Opcode.rs)) { if (MipsRegLo_S(m_Opcode.rs) >= 0) { @@ -2735,7 +2733,7 @@ void CRecompilerOps::SPECIAL_AND (void) ProtectGPR(source1); ProtectGPR(source2); if (Is32Bit(source1) && Is32Bit(source2)) { - int Sign = (IsSigned(m_Opcode.rt) && IsSigned(m_Opcode.rs))?TRUE:FALSE; + bool Sign = (IsSigned(m_Opcode.rt) && IsSigned(m_Opcode.rs))?true:false; Map_GPR_32bit(m_Opcode.rd,Sign,source1); AndX86RegToX86Reg(MipsRegMapLo(m_Opcode.rd),MipsRegMapLo(source2)); } else if (Is32Bit(source1) || Is32Bit(source2)) { @@ -2785,13 +2783,13 @@ void CRecompilerOps::SPECIAL_AND (void) } } else { DWORD Value = cMipsRegLo(ConstReg); - int Sign = FALSE; - if (IsSigned(ConstReg) && IsSigned(MappedReg)) { Sign = TRUE; } + bool Sign = false; + if (IsSigned(ConstReg) && IsSigned(MappedReg)) { Sign = true; } if (Value != 0) { Map_GPR_32bit(m_Opcode.rd,Sign,MappedReg); AndConstToX86Reg(MipsRegMapLo(m_Opcode.rd),Value); } else { - Map_GPR_32bit(m_Opcode.rd,FALSE, 0); + Map_GPR_32bit(m_Opcode.rd,false, 0); } } } diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h index 036c05996..3ed8802f5 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h @@ -274,7 +274,7 @@ protected: { return m_RegWorkingSet.Free8BitX86Reg(); } - static inline void Map_GPR_32bit ( int Reg, BOOL SignValue, int MipsRegToLoad ) + static inline void Map_GPR_32bit ( int Reg, bool SignValue, int MipsRegToLoad ) { m_RegWorkingSet.Map_GPR_32bit(Reg,SignValue,MipsRegToLoad); } diff --git a/Source/Project64/N64 System/Recompiler/Reg Info.cpp b/Source/Project64/N64 System/Recompiler/Reg Info.cpp index d902336f7..ec570a410 100644 --- a/Source/Project64/N64 System/Recompiler/Reg Info.cpp +++ b/Source/Project64/N64 System/Recompiler/Reg Info.cpp @@ -538,30 +538,31 @@ CRegInfo::x86Reg CRegInfo::Map_MemoryStack ( x86Reg Reg, bool bMapRegister, bool return Reg; } -void CRegInfo::Map_GPR_32bit (int MipsReg, BOOL SignValue, int MipsRegToLoad) +void CRegInfo::Map_GPR_32bit (int MipsReg, bool SignValue, int MipsRegToLoad) { int count; x86Reg Reg; - if (MipsReg == 0) { -#ifndef EXTERNAL_RELEASE - _Notify->DisplayError("Map_GPR_32bit\n\nWhy are you trying to map reg 0"); -#endif + if (MipsReg == 0) + { + _Notify->BreakPoint(__FILE__,__LINE__); return; } - if (IsUnknown(MipsReg) || IsConst(MipsReg)) { + if (IsUnknown(MipsReg) || IsConst(MipsReg)) + { Reg = FreeX86Reg(); if (Reg < 0) { #ifndef EXTERNAL_RELEASE _Notify->DisplayError("Map_GPR_32bit\n\nOut of registers"); - _Notify->BreakPoint(__FILE__,__LINE__); #endif + _Notify->BreakPoint(__FILE__,__LINE__); return; } CPU_Message(" regcache: allocate %s to %s",x86_Name(Reg),CRegName::GPR[MipsReg]); } else { - if (Is64Bit(MipsReg)) { + if (Is64Bit(MipsReg)) + { CPU_Message(" regcache: unallocate %s from high 32bit of %s",x86_Name(MipsRegMapHi(MipsReg)),CRegName::GPR_Hi[MipsReg]); SetX86MapOrder(MipsRegMapHi(MipsReg),0); SetX86Mapped(MipsRegMapHi(MipsReg),NotMapped); @@ -573,17 +574,21 @@ void CRegInfo::Map_GPR_32bit (int MipsReg, BOOL SignValue, int MipsRegToLoad) for (count = 0; count < 10; count ++) { DWORD Count = GetX86MapOrder((x86Reg)count); - if ( Count > 0) { + if ( Count > 0) + { SetX86MapOrder((x86Reg)count,Count + 1); } } SetX86MapOrder(Reg,1); - if (MipsRegToLoad > 0) { - if (IsUnknown(MipsRegToLoad)) { + if (MipsRegToLoad > 0) + { + if (IsUnknown(MipsRegToLoad)) + { MoveVariableToX86reg(&_GPR[MipsRegToLoad].UW[0],CRegName::GPR_Lo[MipsRegToLoad],Reg); } else if (IsMapped(MipsRegToLoad)) { - if (MipsReg != MipsRegToLoad) { + if (MipsReg != MipsRegToLoad) + { MoveX86RegToX86Reg(MipsRegMapLo(MipsRegToLoad),Reg); } } else { diff --git a/Source/Project64/N64 System/Recompiler/Reg Info.h b/Source/Project64/N64 System/Recompiler/Reg Info.h index 03b588147..98714f5ec 100644 --- a/Source/Project64/N64 System/Recompiler/Reg Info.h +++ b/Source/Project64/N64 System/Recompiler/Reg Info.h @@ -67,7 +67,7 @@ public: x86Reg FreeX86Reg ( void ); x86Reg Free8BitX86Reg ( void ); - void Map_GPR_32bit ( int MipsReg, BOOL SignValue, int MipsRegToLoad ); + void Map_GPR_32bit ( int MipsReg, bool SignValue, int MipsRegToLoad ); void Map_GPR_64bit ( int MipsReg, int MipsRegToLoad ); x86Reg Get_MemoryStack ( void ) const; x86Reg Map_MemoryStack ( x86Reg Reg, bool bMapRegister, bool LoadValue = true );