Skip to content

Commit

Permalink
Cleaning up code for SP registers update.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinnegatamante committed Mar 31, 2023
1 parent 04b8c92 commit 650c423
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
26 changes: 6 additions & 20 deletions Source/Core/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,26 +633,11 @@ void MemoryUpdateSPStatus( u32 flags )
if (flags & SP_SET_SIG7) DBGConsole_Msg( 0, "SP: Setting Sig7" );
#endif

bool start_rsp = false;
//bool stop_rsp = false;

u32 clr_bits = 0, set_bits = 0;

if (flags & SP_CLR_HALT) {
clr_bits |= SP_STATUS_HALT;
start_rsp = true;
}

if (flags & SP_SET_HALT) {
set_bits |= SP_STATUS_HALT;
//stop_rsp = true;
}

if (flags & SP_CLR_BROKE)
{
clr_bits |= SP_STATUS_BROKE;
start_rsp = true;
}
if (flags & SP_CLR_HALT) clr_bits |= SP_STATUS_HALT;
if (flags & SP_SET_HALT) set_bits |= SP_STATUS_HALT;
if (flags & SP_CLR_BROKE) clr_bits |= SP_STATUS_BROKE;

if (flags & SP_CLR_INTR)
{
Expand All @@ -665,7 +650,7 @@ void MemoryUpdateSPStatus( u32 flags )
Memory_MI_SetRegisterBits(MI_INTR_REG, MI_INTR_SP);
R4300_Interrupt_UpdateCause3();
}

if (flags & SP_CLR_SSTEP) clr_bits |= SP_STATUS_SSTEP;
if (flags & SP_SET_SSTEP) set_bits |= SP_STATUS_SSTEP;
if (flags & SP_CLR_INTR_BREAK) clr_bits |= SP_STATUS_INTR_BREAK;
Expand All @@ -692,7 +677,8 @@ void MemoryUpdateSPStatus( u32 flags )
//
// We execute the task here, after we've written to the SP status register.
//
if( start_rsp )
uint32_t registers = Memory_SP_GetRegisterBits( SP_STATUS_REG );
if (!( registers & (SP_STATUS_HALT | SP_STATUS_BROKE) ))
{
// Check for tasks whenever the RSP is started
RSP_HLE_ProcessTask();
Expand Down
6 changes: 6 additions & 0 deletions Source/Core/Memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ inline void Write8Bits_NoSwizzle( u32 address, u8 data ) {
return AtomicBitSet( p, and_bits, or_bits ); \
} \
\
inline u32 Memory_##set##_GetRegisterBits( u32 reg ) \
{ \
u32 * p( &((u32 *)g_pMemoryBuffers[memory_buffer])[ (reg - base_reg) / 4 ] ); \
return *p; \
} \
\
inline u32 Memory_##set##_SetRegisterBits( u32 reg, u32 value ) \
{ \
u32 * p( &((u32 *)g_pMemoryBuffers[memory_buffer])[ (reg - base_reg) / 4 ] ); \
Expand Down

0 comments on commit 650c423

Please sign in to comment.