wDsp.cpp (1141B)
1 #include "wDsp.h" 2 3 #include "dsp56kEmu/dsp.h" 4 #include "dsp56kEmu/jitconfig.h" 5 6 namespace wLib 7 { 8 void Dsp::enableDynamicPeripheralAddressing(dsp56k::JitConfig& _config, dsp56k::DSP& _dsp, dsp56k::TWord _opA, dsp56k::TWord _opB, dsp56k::TWord _size) 9 { 10 // some startup code uses dynamic peripheral addressing, we allow this only for that code segment 11 _config.getBlockConfig = [this, _opA, _opB, _size, &_dsp](const dsp56k::TWord _pc) -> std::optional<dsp56k::JitConfig> 12 { 13 for (const auto& [start, size] : m_dynamicPeripheralAddressingRanges) 14 { 15 if(_pc < start || _pc > start + size) 16 continue; 17 18 auto c = _dsp.getJit().getConfig(); 19 c.dynamicPeripheralAddressing = true; 20 return c; 21 } 22 23 // find the op as specified by parameters 24 // clr b M_AAR3,r2 25 const auto opA = _dsp.memory().get(dsp56k::MemArea_P, _pc); 26 const auto opB = _dsp.memory().get(dsp56k::MemArea_P, _pc + 1); 27 28 if(opA == _opA && opB == _opB) 29 { 30 m_dynamicPeripheralAddressingRanges.insert({_pc, _size}); 31 auto c = _dsp.getJit().getConfig(); 32 c.dynamicPeripheralAddressing = true; 33 return c; 34 } 35 36 return {}; 37 }; 38 } 39 }