Skip to content

Commit

Permalink
Core: Change TriggerAddressException to SetVPN an R of entry hi in on…
Browse files Browse the repository at this point in the history
…e call
  • Loading branch information
project64 committed Nov 23, 2023
1 parent d47b49d commit 01673da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
16 changes: 4 additions & 12 deletions Source/Project64-core/N64System/Mips/Register.cpp
Expand Up @@ -238,16 +238,10 @@ uint32_t COP0EntryHi::R() const
return (uint32_t)((Value >> 62) & 0x3);
}

void COP0EntryHi::SetVPN2(uint32_t VPN2)
void COP0EntryHi::SetFromAddress(const uint64_t & Address)
{
Value &= ~(0x7FFFFFFFll << 13);
Value |= ((uint64_t)(VPN2 & 0x7FFFFFFF)) << 13;
}

void COP0EntryHi::SetR(uint32_t R)
{
Value &= ~(0x3ll << 62ll);
Value |= ((uint64_t)(R & 0x3)) << 62;
Value &= ~0xC0000FFFFFFFE000;
Value |= Address & 0xC00000FFFFFFE000;
}

CP0registers::CP0registers(uint64_t * _CP0) :
Expand Down Expand Up @@ -794,10 +788,8 @@ void CRegisters::TriggerAddressException(uint64_t Address, uint32_t ExceptionCod
ExceptionCode = EXC_MOD;
}
}

BAD_VADDR_REGISTER = Address;
ENTRYHI_REGISTER.SetVPN2((Address >> 13) & 0x7FFFFFF);
ENTRYHI_REGISTER.SetR(Address >> 62);
ENTRYHI_REGISTER.SetFromAddress(Address);
CONTEXT_REGISTER.BadVPN2 = Address >> 13;
XCONTEXT_REGISTER.BadVPN2 = Address >> 13;
XCONTEXT_REGISTER.R = Address >> 62;
Expand Down
3 changes: 1 addition & 2 deletions Source/Project64-core/N64System/Mips/Register.h
Expand Up @@ -56,8 +56,7 @@ union COP0EntryHi
uint32_t FILL() const;
uint32_t R() const;

void SetVPN2(uint32_t VPN2);
void SetR(uint32_t R);
void SetFromAddress(const uint64_t & Address);

struct
{
Expand Down

0 comments on commit 01673da

Please sign in to comment.