dspMemoryPatch.h (1598B)
1 #pragma once 2 3 #include "baseLib/md5.h" 4 5 #include "dsp56kEmu/types.h" 6 7 namespace dsp56k 8 { 9 class DSP; 10 } 11 12 namespace synthLib 13 { 14 namespace dspOpcodes 15 { 16 static constexpr dsp56k::TWord g_nop = 0x000000; 17 static constexpr dsp56k::TWord g_wait = 0x000086; 18 } 19 20 struct DspMemoryPatch 21 { 22 dsp56k::EMemArea area = dsp56k::MemArea_COUNT; 23 dsp56k::TWord address = 0; 24 dsp56k::TWord expectedOldValue = 0; 25 dsp56k::TWord newValue = 0; 26 27 constexpr bool operator == (const DspMemoryPatch& _p) const 28 { 29 return area == _p.area && address == _p.address && expectedOldValue == _p.expectedOldValue && newValue == _p.newValue; 30 } 31 32 constexpr bool operator != (const DspMemoryPatch& _p) const 33 { 34 return !(*this == _p); 35 } 36 37 constexpr bool operator < (const DspMemoryPatch& _p) const 38 { 39 if(area < _p.area) return true; 40 if(area > _p.area) return false; 41 if(address < _p.address) return true; 42 if(address > _p.address) return false; 43 if(expectedOldValue < _p.expectedOldValue) return true; 44 if(expectedOldValue > _p.expectedOldValue) return false; 45 if(newValue < _p.newValue) return true; 46 /*if(newValue > _p.newValue)*/ return false; 47 } 48 49 std::string toString() const; 50 }; 51 52 struct DspMemoryPatches 53 { 54 std::initializer_list<baseLib::MD5> allowedTargets; 55 std::initializer_list<DspMemoryPatch> patches; 56 57 bool apply(dsp56k::DSP& _dsp, const baseLib::MD5& _md5) const; 58 59 private: 60 static bool apply(dsp56k::DSP& _dsp, const std::initializer_list<DspMemoryPatch>& _patches); 61 static bool apply(dsp56k::DSP& _dsp, const DspMemoryPatch& _patch); 62 }; 63 }