From 34dab07f8323b096690aece3112c5c90227cb771 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 22 Dec 2015 08:41:49 +1100 Subject: [PATCH] [Project64] Add Write32SPRegisters --- .../N64System/Mips/MemoryVirtualMem.cpp | 290 +++++++++--------- .../N64System/Mips/MemoryVirtualMem.h | 1 + 2 files changed, 150 insertions(+), 141 deletions(-) diff --git a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp index 3d9da0d5c..72a74244b 100644 --- a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp +++ b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.cpp @@ -2657,147 +2657,7 @@ bool CMipsMemoryVM::SW_NonMemory(uint32_t PAddr, uint32_t Value) } else { - switch (PAddr) - { - case 0x04040000: g_Reg->SP_MEM_ADDR_REG = Value; break; - case 0x04040004: g_Reg->SP_DRAM_ADDR_REG = Value; break; - case 0x04040008: - g_Reg->SP_RD_LEN_REG = Value; - SP_DMA_READ(); - break; - case 0x0404000C: - g_Reg->SP_WR_LEN_REG = Value; - SP_DMA_WRITE(); - break; - case 0x04040010: - if ((Value & SP_CLR_HALT) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_HALT; - } - if ((Value & SP_SET_HALT) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_HALT; - } - if ((Value & SP_CLR_BROKE) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_BROKE; - } - if ((Value & SP_CLR_INTR) != 0) - { - g_Reg->MI_INTR_REG &= ~MI_INTR_SP; - g_Reg->m_RspIntrReg &= ~MI_INTR_SP; - g_Reg->CheckInterrupts(); - } - if ((Value & SP_SET_INTR) != 0) - { - g_Notify->DisplayError(L"SP_SET_INTR"); - } - if ((Value & SP_CLR_SSTEP) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SSTEP; - } - if ((Value & SP_SET_SSTEP) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SSTEP; - } - if ((Value & SP_CLR_INTR_BREAK) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_INTR_BREAK; - } - if ((Value & SP_SET_INTR_BREAK) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_INTR_BREAK; - } - if ((Value & SP_CLR_SIG0) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG0; - } - if ((Value & SP_SET_SIG0) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG0; - } - if ((Value & SP_CLR_SIG1) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG1; - } - if ((Value & SP_SET_SIG1) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG1; - } - if ((Value & SP_CLR_SIG2) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG2; - } - if ((Value & SP_SET_SIG2) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG2; - } - if ((Value & SP_CLR_SIG3) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG3; - } - if ((Value & SP_SET_SIG3) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG3; - } - if ((Value & SP_CLR_SIG4) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG4; - } - if ((Value & SP_SET_SIG4) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG4; - } - if ((Value & SP_CLR_SIG5) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG5; - } - if ((Value & SP_SET_SIG5) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG5; - } - if ((Value & SP_CLR_SIG6) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG6; - } - if ((Value & SP_SET_SIG6) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG6; - } - if ((Value & SP_CLR_SIG7) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG7; - } - if ((Value & SP_SET_SIG7) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG7; - } - if ((Value & SP_SET_SIG0) != 0 && g_System->RspAudioSignal()) - { - g_Reg->MI_INTR_REG |= MI_INTR_SP; - g_Reg->CheckInterrupts(); - } - //if (*( uint32_t *)(DMEM + 0xFC0) == 1) - //{ - // ChangeTimer(RspTimer,0x30000); - //} - //else - //{ - try - { - g_System->RunRSP(); - } - catch (...) - { - g_Notify->BreakPoint(__FILE__, __LINE__); - } - //} - break; - case 0x0404001C: g_Reg->SP_SEMAPHORE_REG = 0; break; - case 0x04080000: g_Reg->SP_PC_REG = Value & 0xFFC; break; - default: - return false; - } + Write32SPRegisters(); } break; case 0x04100000: @@ -5722,4 +5582,152 @@ void CMipsMemoryVM::Write32RDRAMRegisters(void) g_Notify->BreakPoint(__FILE__, __LINE__); } } +} + +void CMipsMemoryVM::Write32SPRegisters(void) +{ + switch ((m_MemLookupAddress & 0xFFFFFFF)) + { + case 0x04040000: g_Reg->SP_MEM_ADDR_REG = m_MemLookupValue.UW[0]; break; + case 0x04040004: g_Reg->SP_DRAM_ADDR_REG = m_MemLookupValue.UW[0]; break; + case 0x04040008: + g_Reg->SP_RD_LEN_REG = m_MemLookupValue.UW[0]; + g_MMU->SP_DMA_READ(); + break; + case 0x0404000C: + g_Reg->SP_WR_LEN_REG = m_MemLookupValue.UW[0]; + g_MMU->SP_DMA_WRITE(); + break; + case 0x04040010: + if ((m_MemLookupValue.UW[0] & SP_CLR_HALT) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_HALT; + } + if ((m_MemLookupValue.UW[0] & SP_SET_HALT) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_HALT; + } + if ((m_MemLookupValue.UW[0] & SP_CLR_BROKE) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_BROKE; + } + if ((m_MemLookupValue.UW[0] & SP_CLR_INTR) != 0) + { + g_Reg->MI_INTR_REG &= ~MI_INTR_SP; + g_Reg->m_RspIntrReg &= ~MI_INTR_SP; + g_Reg->CheckInterrupts(); + } + if ((m_MemLookupValue.UW[0] & SP_SET_INTR) != 0) + { + g_Notify->DisplayError(L"SP_SET_INTR"); + } + if ((m_MemLookupValue.UW[0] & SP_CLR_SSTEP) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SSTEP; + } + if ((m_MemLookupValue.UW[0] & SP_SET_SSTEP) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SSTEP; + } + if ((m_MemLookupValue.UW[0] & SP_CLR_INTR_BREAK) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_INTR_BREAK; + } + if ((m_MemLookupValue.UW[0] & SP_SET_INTR_BREAK) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_INTR_BREAK; + } + if ((m_MemLookupValue.UW[0] & SP_CLR_SIG0) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG0; + } + if ((m_MemLookupValue.UW[0] & SP_SET_SIG0) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG0; + } + if ((m_MemLookupValue.UW[0] & SP_CLR_SIG1) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG1; + } + if ((m_MemLookupValue.UW[0] & SP_SET_SIG1) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG1; + } + if ((m_MemLookupValue.UW[0] & SP_CLR_SIG2) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG2; + } + if ((m_MemLookupValue.UW[0] & SP_SET_SIG2) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG2; + } + if ((m_MemLookupValue.UW[0] & SP_CLR_SIG3) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG3; + } + if ((m_MemLookupValue.UW[0] & SP_SET_SIG3) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG3; + } + if ((m_MemLookupValue.UW[0] & SP_CLR_SIG4) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG4; + } + if ((m_MemLookupValue.UW[0] & SP_SET_SIG4) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG4; + } + if ((m_MemLookupValue.UW[0] & SP_CLR_SIG5) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG5; + } + if ((m_MemLookupValue.UW[0] & SP_SET_SIG5) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG5; + } + if ((m_MemLookupValue.UW[0] & SP_CLR_SIG6) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG6; + } + if ((m_MemLookupValue.UW[0] & SP_SET_SIG6) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG6; + } + if ((m_MemLookupValue.UW[0] & SP_CLR_SIG7) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG7; + } + if ((m_MemLookupValue.UW[0] & SP_SET_SIG7) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG7; + } + if ((m_MemLookupValue.UW[0] & SP_SET_SIG0) != 0 && g_System->RspAudioSignal()) + { + g_Reg->MI_INTR_REG |= MI_INTR_SP; + g_Reg->CheckInterrupts(); + } + //if (*( uint32_t *)(DMEM + 0xFC0) == 1) + //{ + // ChangeTimer(RspTimer,0x30000); + //} + //else + //{ + try + { + g_System->RunRSP(); + } + catch (...) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } + //} + break; + case 0x0404001C: g_Reg->SP_SEMAPHORE_REG = 0; break; + case 0x04080000: g_Reg->SP_PC_REG = m_MemLookupValue.UW[0] & 0xFFC; break; + default: + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILE__, __LINE__); + } +} } \ No newline at end of file diff --git a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h index 60b2b3da0..4d4bcba36 100644 --- a/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h +++ b/Source/Project64-core/N64System/Mips/MemoryVirtualMem.h @@ -197,6 +197,7 @@ private: static void Load32Rom(void); static void Write32RDRAMRegisters(void); + static void Write32SPRegisters(void); CMipsMemory_CallBack * const m_CBClass;