Better throttling.

This commit is contained in:
Jean-Philip Desjardins 2023-09-26 18:27:55 -04:00
parent cf2a32c857
commit 3c57322bd4
2 changed files with 5 additions and 10 deletions

View file

@ -325,6 +325,7 @@ uint16 CSpuBase::GetControl() const
void CSpuBase::SetControl(uint16 value) void CSpuBase::SetControl(uint16 value)
{ {
m_ctrl = value; m_ctrl = value;
m_transferTicks = 0;
if((m_ctrl & CONTROL_IRQ) == 0) if((m_ctrl & CONTROL_IRQ) == 0)
{ {
ClearIrqPending(); ClearIrqPending();
@ -378,6 +379,7 @@ uint16 CSpuBase::GetTransferMode() const
void CSpuBase::SetTransferMode(uint16 transferMode) void CSpuBase::SetTransferMode(uint16 transferMode)
{ {
m_transferMode = transferMode; m_transferMode = transferMode;
m_transferTicks = 0;
} }
uint32 CSpuBase::GetTransferAddress() const uint32 CSpuBase::GetTransferAddress() const
@ -591,6 +593,7 @@ uint32 CSpuBase::ReceiveDma(uint8* buffer, uint32 blockSize, uint32 blockAmount,
uint32 availableBytes = SOUND_INPUT_DATA_SIZE - m_blockWritePtr; uint32 availableBytes = SOUND_INPUT_DATA_SIZE - m_blockWritePtr;
uint32 availableBlocks = availableBytes / blockSize; uint32 availableBlocks = availableBytes / blockSize;
blockAmount = std::min({blockAmount, availableBlocks, blockTicks}); blockAmount = std::min({blockAmount, availableBlocks, blockTicks});
m_transferTicks -= (g_transferTicksPerBlock * blockAmount);
uint32 dstAddr = m_soundInputDataAddr + m_blockWritePtr; uint32 dstAddr = m_soundInputDataAddr + m_blockWritePtr;
memcpy(m_ram + dstAddr, buffer, blockAmount * blockSize); memcpy(m_ram + dstAddr, buffer, blockAmount * blockSize);
@ -811,15 +814,7 @@ void CSpuBase::Render(int16* samples, unsigned int sampleCount)
} }
} }
switch(m_ctrl & CONTROL_DMA) m_transferTicks += sampleCount;
{
case CONTROL_DMA_STOP:
m_transferTicks = 0;
break;
default:
m_transferTicks += sampleCount;
break;
}
} }
uint32 CSpuBase::GetAdsrDelta(unsigned int index) const uint32 CSpuBase::GetAdsrDelta(unsigned int index) const

View file

@ -374,7 +374,7 @@ namespace Iop
static const uint32 g_linearIncreaseSweepDeltas[0x80]; static const uint32 g_linearIncreaseSweepDeltas[0x80];
static const uint32 g_linearDecreaseSweepDeltas[0x80]; static const uint32 g_linearDecreaseSweepDeltas[0x80];
static constexpr int32 g_transferTicksPerBlock = 16; static constexpr int32 g_transferTicksPerBlock = 8;
uint8* m_ram; uint8* m_ram;
uint32 m_ramSize; uint32 m_ramSize;