gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit e71b1580acbd88776070139cccd57b7ac5ced25a
parent 97c49f763194fa7bbbb867df3e941311d8f23353
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Tue,  9 Jul 2024 22:36:04 +0200

use dynamic peripheral addressing only for startup code, disable for everything else

Diffstat:
Msource/xtLib/xtDSP.cpp | 26+++++++++++++++++++++++++-
Msource/xtLib/xtDSP.h | 2++
2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/source/xtLib/xtDSP.cpp b/source/xtLib/xtDSP.cpp @@ -8,6 +8,7 @@ #endif #include "../mc68k/hdi08.h" +#include "dsp56kEmu/aar.h" #include "dsp56kEmu/types.h" namespace xt @@ -33,9 +34,32 @@ namespace xt config.aguSupportBitreverse = true; config.linkJitBlocks = true; - config.dynamicPeripheralAddressing = true; + config.dynamicPeripheralAddressing = false; config.maxInstructionsPerBlock = 0; + // some startup code uses dynamic peripheral addressing, we allow this only for that code segment + config.getBlockConfig = [this](const dsp56k::TWord _pc) -> std::optional<dsp56k::JitConfig> + { + if(m_dynamicPeripheralAddressingStart == 0) + { + // find the following op: + // clr b M_AAR3,r2 + const auto opA = m_dsp.memory().get(dsp56k::MemArea_P, _pc); + const auto opB = m_dsp.memory().get(dsp56k::MemArea_P, _pc + 1); + if(opA == 0x62f41b && opB == dsp56k::M_AAR3) + { + m_dynamicPeripheralAddressingStart = _pc; + } + } + + // enable DPA for the address of the op we found + 16 words + if(_pc < m_dynamicPeripheralAddressingStart || _pc > m_dynamicPeripheralAddressingStart + 16) + return {}; + auto c = m_dsp.getJit().getConfig(); + c.dynamicPeripheralAddressing = true; + return c; + }; + m_dsp.getJit().setConfig(config); // fill P memory with something that reminds us if we jump to garbage diff --git a/source/xtLib/xtDSP.h b/source/xtLib/xtDSP.h @@ -72,5 +72,7 @@ namespace xt uint32_t m_hdiHF01 = 0; // uc => DSP std::unique_ptr<dsp56k::DSPThread> m_thread; + + uint32_t m_dynamicPeripheralAddressingStart = 0; }; }