bsnes/fc/cheat/cheat.cpp

29 lines
515 B
C++

#include <fc/fc.hpp>
namespace Famicom {
Cheat cheat;
void Cheat::reset() {
codes.reset();
}
void Cheat::append(unsigned addr, unsigned data) {
codes.append({addr, Unused, data});
}
void Cheat::append(unsigned addr, unsigned comp, unsigned data) {
codes.append({addr, comp, data});
}
maybe<unsigned> Cheat::find(unsigned addr, unsigned comp) {
for(auto& code : codes) {
if(code.addr == addr && (code.comp == Unused || code.comp == comp)) {
return code.data;
}
}
return nothing;
}
}