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 9a2d176ba019478062db3e9a1a9fe27a827fc64b
parent a7e304bc009fb1c5f9fe52c6666cd7b6dee22eac
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Wed, 10 Jul 2024 23:33:04 +0200

disable dynamic peripheral addressing for Vavra too, only allow it for specific code snippets

Diffstat:
Msource/mqLib/mqdsp.cpp | 10+++++++++-
Msource/wLib/wDsp.cpp | 39+++++++++++++++++++++++++++++++++++++++
Msource/wLib/wDsp.h | 15+++++++++++++++
Msource/xtLib/xtDSP.cpp | 28+++++-----------------------
Msource/xtLib/xtDSP.h | 2--
5 files changed, 68 insertions(+), 26 deletions(-)

diff --git a/source/mqLib/mqdsp.cpp b/source/mqLib/mqdsp.cpp @@ -10,6 +10,8 @@ #include "../wLib/dspBootCode.h" +#include "dsp56kEmu/aar.h" + namespace mqLib { static dsp56k::DefaultMemoryValidator g_memoryValidator; @@ -34,9 +36,15 @@ namespace mqLib config.aguSupportBitreverse = true; config.linkJitBlocks = true; - config.dynamicPeripheralAddressing = true; + config.dynamicPeripheralAddressing = false; +#ifdef _DEBUG + config.debugDynamicPeripheralAddressing = true; +#endif config.maxInstructionsPerBlock = 0; // TODO: needs to be 1 if DSP factory tests are run, to be investigated + // allow dynamic peripheral addressing for code following clr b M_AAR3,r2 + enableDynamicPeripheralAddressing(config, m_dsp, 0x62f41b, dsp56k::M_AAR3, 16); + m_dsp.getJit().setConfig(config); // fill P memory with something that reminds us if we jump to garbage diff --git a/source/wLib/wDsp.cpp b/source/wLib/wDsp.cpp @@ -0,0 +1,39 @@ +#include "wDsp.h" + +#include "dsp56kEmu/dsp.h" +#include "dsp56kEmu/jitconfig.h" + +namespace wLib +{ + void Dsp::enableDynamicPeripheralAddressing(dsp56k::JitConfig& _config, dsp56k::DSP& _dsp, dsp56k::TWord _opA, dsp56k::TWord _opB, dsp56k::TWord _size) + { + // some startup code uses dynamic peripheral addressing, we allow this only for that code segment + _config.getBlockConfig = [this, _opA, _opB, _size, &_dsp](const dsp56k::TWord _pc) -> std::optional<dsp56k::JitConfig> + { + for (const auto& [start, size] : m_dynamicPeripheralAddressingRanges) + { + if(_pc < start || _pc > start + size) + continue; + + auto c = _dsp.getJit().getConfig(); + c.dynamicPeripheralAddressing = true; + return c; + } + + // find the op as specified by parameters + // clr b M_AAR3,r2 + const auto opA = _dsp.memory().get(dsp56k::MemArea_P, _pc); + const auto opB = _dsp.memory().get(dsp56k::MemArea_P, _pc + 1); + + if(opA == _opA && opB == _opB) + { + m_dynamicPeripheralAddressingRanges.insert({_pc, _size}); + auto c = _dsp.getJit().getConfig(); + c.dynamicPeripheralAddressing = true; + return c; + } + + return {}; + }; + } +} diff --git a/source/wLib/wDsp.h b/source/wLib/wDsp.h @@ -1,8 +1,23 @@ #pragma once +#include <unordered_map> + +#include "dsp56kEmu/types.h" + +namespace dsp56k +{ + class DSP; + struct JitConfig; +} + namespace wLib { class Dsp { + protected: + void enableDynamicPeripheralAddressing(dsp56k::JitConfig& _config, dsp56k::DSP& _dsp, dsp56k::TWord _opA, dsp56k::TWord _opB, dsp56k::TWord _size); + + private: + std::unordered_map<dsp56k::TWord, dsp56k::TWord> m_dynamicPeripheralAddressingRanges; }; } diff --git a/source/xtLib/xtDSP.cpp b/source/xtLib/xtDSP.cpp @@ -35,30 +35,12 @@ namespace xt config.aguSupportBitreverse = true; config.linkJitBlocks = 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; - } - } +#ifdef _DEBUG + config.debugDynamicPeripheralAddressing = true; +#endif - // 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; - }; + // allow dynamic peripheral addressing for code following clr b M_AAR3,r2 + enableDynamicPeripheralAddressing(config, m_dsp, 0x62f41b, dsp56k::M_AAR3, 16); m_dsp.getJit().setConfig(config); diff --git a/source/xtLib/xtDSP.h b/source/xtLib/xtDSP.h @@ -72,7 +72,5 @@ namespace xt uint32_t m_hdiHF01 = 0; // uc => DSP std::unique_ptr<dsp56k::DSPThread> m_thread; - - uint32_t m_dynamicPeripheralAddressingStart = 0; }; }