Skip to content

Commit

Permalink
Core: Improve StoreInstruc
Browse files Browse the repository at this point in the history
  • Loading branch information
project64 committed Jan 9, 2023
1 parent ccae22a commit 531a7df
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ void PeripheralInterfaceHandler::OnFirstDMA()
g_Notify->DisplayError(stdstr_f("Unhandled CicChip(%d) in first DMA", g_Rom->CicChipID()).c_str());
return;
}
m_MMU.UpdateMemoryValue32(0x80000000 + offset, m_MMU.RdramSize());

m_MMU.SW_Memory(0xFFFFFFFF80000000 + offset, m_MMU.RdramSize());
}

void PeripheralInterfaceHandler::PI_DMA_READ()
Expand Down Expand Up @@ -377,6 +378,11 @@ void PeripheralInterfaceHandler::PI_DMA_WRITE()
else
{
int32_t Length = PI_WR_LEN_REG + 1;
if (g_Recompiler && bSMM_PIDMA())
{
g_Recompiler->ClearRecompCode_Phys(WritePos & ~0xFFF, Length, CRecompiler::Remove_DMA);
}

PI_WR_LEN_REG = Length <= 8 ? 0x7F - (PI_DRAM_ADDR_REG & 7) : 0x7F;

uint8_t Block[128];
Expand Down Expand Up @@ -468,10 +474,6 @@ void PeripheralInterfaceHandler::PI_DMA_WRITE()
MI_INTR_REG |= MI_INTR_PI;
m_Reg.CheckInterrupts();
}
if (g_Recompiler && g_System->bSMM_PIDMA())
{
g_Recompiler->ClearRecompCode_Phys(WritePos, Length, CRecompiler::Remove_DMA);
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,8 @@ bool CMipsMemoryVM::SW_NonMemory(uint32_t VAddr, uint32_t Value)
}
if (CGameSettings::bSMM_StoreInstruc())
{
m_TLB_WriteMap[VAddr >> 12] = PAddr - VAddr;
m_TLB_WriteMap[(0x80000000 + PAddr) >> 12] = PAddr - VAddr;
m_TLB_WriteMap[(0xA0000000 + PAddr) >> 12] = PAddr - VAddr;
}
*(uint32_t *)(m_RDRAM + PAddr) = Value;
}
Expand Down Expand Up @@ -950,7 +951,7 @@ void CMipsMemoryVM::ClearMemoryWriteMap(uint32_t VAddr, uint32_t Length)
return;
}
uint32_t PAddr = m_TLB_ReadMap[VAddr >> 12] + VAddr;
for (uint32_t i = PAddr, n = (PAddr + Length) + 0x1000; i < n; i += 0x1000)
for (uint32_t i = PAddr, n = (PAddr + (Length & ~0xFFF)) + 0x1000; i < n; i += 0x1000)
{
m_MemoryWriteMap[(i + 0x80000000) >> 12] = (size_t)-1;
m_MemoryWriteMap[(i + 0xA0000000) >> 12] = (size_t)-1;
Expand Down
5 changes: 5 additions & 0 deletions Source/Project64-core/N64System/Recompiler/Recompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@ CCompiledFunc * CRecompiler::CompileCode()
*g_RecompPos += CodeLen;
LogCodeBlock(CodeBlock);

if (bSMM_StoreInstruc())
{
m_MMU.ClearMemoryWriteMap(CodeBlock.VAddrEnter() & ~0xFFF, 0xFFF);
}

CCompiledFunc * Func = new CCompiledFunc(CodeBlock);
std::pair<CCompiledFuncList::iterator, bool> ret = m_Functions.insert(CCompiledFuncList::value_type(Func->EnterPC(), Func));
if (ret.second == false)
Expand Down

0 comments on commit 531a7df

Please sign in to comment.