mirror of
https://github.com/libretro/bsnes-libretro.git
synced 2024-11-23 17:09:44 +00:00
a03d91882c
byuu says: - bsnes: allow video filtering even when the emulator is paused - bsnes: improve overscan masking, especially with HD mode 7 - bsnes: improve snow support, especially with HD mode 7 - bsnes: replace real-time cheat code replace with per-frame replace (ala Pro Action Replay, Snes9X) - bsnes: treat the latter step() half of CPU::read() calls as idle cycles - bsnes: templatize step() where possible (not always practical) - bsnes: removed Natural<T> templates from key portions of the fast PPU renderer - bsnes: dethreaded peripherals (controllers and expansion port devices) - bsnes: above optimizations result in a ~20-25% speedup over v107.4 with no accuracy loss Note that light guns aren't going to work for now, I'll have to fix them before we can release v108.
58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
#pragma once
|
|
|
|
namespace Emulator {
|
|
|
|
struct Cheat {
|
|
struct Code {
|
|
auto operator==(const Code& code) const -> bool {
|
|
if(address != code.address) return false;
|
|
if(data != code.data) return false;
|
|
if((bool)compare != (bool)code.compare) return false;
|
|
if(compare && code.compare && compare() != code.compare()) return false;
|
|
return true;
|
|
}
|
|
|
|
uint address;
|
|
uint data;
|
|
maybe<uint> compare;
|
|
bool enable;
|
|
uint restore;
|
|
};
|
|
|
|
explicit operator bool() const {
|
|
return codes.size() > 0;
|
|
}
|
|
|
|
auto reset() -> void {
|
|
codes.reset();
|
|
}
|
|
|
|
auto append(uint address, uint data, maybe<uint> compare = {}) -> void {
|
|
codes.append({address, data, compare});
|
|
}
|
|
|
|
auto assign(const vector<string>& list) -> void {
|
|
reset();
|
|
for(auto& entry : list) {
|
|
for(auto code : entry.split("+")) {
|
|
auto part = code.transform("=?", "//").split("/");
|
|
if(part.size() == 2) append(part[0].hex(), part[1].hex());
|
|
if(part.size() == 3) append(part[0].hex(), part[2].hex(), part[1].hex());
|
|
}
|
|
}
|
|
}
|
|
|
|
auto find(uint address, uint compare) -> maybe<uint> {
|
|
for(auto& code : codes) {
|
|
if(code.address == address && (!code.compare || code.compare() == compare)) {
|
|
return code.data;
|
|
}
|
|
}
|
|
return nothing;
|
|
}
|
|
|
|
vector<Code> codes;
|
|
};
|
|
|
|
}
|