SPC<-->DSP use two sets of registers.

This commit is contained in:
BearOso 2023-03-16 14:42:23 -05:00
parent d45bf0689a
commit 410c52a7c9
2 changed files with 13 additions and 2 deletions

View File

@ -55,9 +55,11 @@ static BOOST::uint8_t const initial_regs [SPC_DSP::register_count] =
// Access global DSP register
#define REG(n) m.regs [r_##n]
#define XREG(n) m.external_regs [r_##n]
// Access voice DSP register
#define VREG(r,n) r [v_##n]
#define XVREG(r,n) (m.external_regs + (r - m.regs))[v_##n]
#define WRITE_SAMPLES( l, r, out ) \
{\
@ -927,6 +929,7 @@ inline VOICE_CLOCK( V7 )
{
// Update ENDX
REG(endx) = m.endx_buf;
XREG(endx) = m.endx_buf;
m.envx_buf = v->t_envx_out;
}
@ -934,11 +937,13 @@ inline VOICE_CLOCK( V8 )
{
// Update OUTX
VREG(v->regs,outx) = m.outx_buf;
XVREG(v->regs,outx) = m.outx_buf;
}
inline VOICE_CLOCK( V9 )
{
// Update ENVX
VREG(v->regs,envx) = m.envx_buf;
XVREG(v->regs,envx) = m.envx_buf;
}
// Most voices do all these in one clock, so make a handy composite
@ -1237,7 +1242,9 @@ void SPC_DSP::soft_reset()
void SPC_DSP::load( uint8_t const regs [register_count] )
{
memcpy( m.regs, regs, sizeof m.regs );
memcpy( m.external_regs, regs, sizeof m.regs );
memset( m.regs, 0, sizeof m.regs);
m.regs[r_flg] = 0xE0;
memset( &m.regs [register_count], 0, offsetof (state_t,ram) - register_count );
// Internal state
@ -1398,6 +1405,7 @@ void SPC_DSP::copy_state( unsigned char** io, copy_func_t copy )
SPC_COPY( uint16_t, m.t_echo_ptr );
SPC_COPY( uint8_t, m.t_looped );
copier.copy(m.external_regs, register_count);
copier.extra();
}
#endif

View File

@ -204,6 +204,8 @@ private:
sample_t extra [extra_size];
uint8_t separate_echo_buffer [0x10000];
uint8_t external_regs [register_count];
};
state_t m;
@ -260,7 +262,7 @@ inline int SPC_DSP::sample_count() const { return m.out - m.out_begin; }
inline int SPC_DSP::read( int addr ) const
{
assert( (unsigned) addr < register_count );
return m.regs [addr];
return m.external_regs [addr];
}
inline void SPC_DSP::write( int addr, int data )
@ -268,6 +270,7 @@ inline void SPC_DSP::write( int addr, int data )
assert( (unsigned) addr < register_count );
m.regs [addr] = (uint8_t) data;
m.external_regs [addr] = (uint8_t) data;
switch ( addr & 0x0F )
{
case v_envx: