bsnes/higan/emulator/cheat.hpp

49 lines
971 B
C++
Raw Normal View History

#pragma once
namespace Emulator {
struct Cheat {
struct Code {
uint addr;
uint data;
maybe<uint> comp;
};
explicit operator bool() const {
return codes.size() > 0;
}
auto reset() -> void {
codes.reset();
}
auto append(uint addr, uint data, maybe<uint> comp = {}) -> void {
codes.append({addr, data, comp});
}
auto assign(const vector<string>& list) -> void {
reset();
for(auto& entry : list) {
for(auto code : entry.split("+")) {
Update to v103 WIP release. byuu says (in the WIP forum): Changelog: - higan: cheat codes accept = and ? separators now - the new preferred code format is: address=value or address=if-match?value - the old code format of address/value and address/if-match/value will continue to work - higan: cheats.bml is no longer included with the base distribution - mightymo stopped updating it in 2015, and it's not source code; it can still be pulled in from older releases - fc: improved PAL mode timing; use PAL APU timing tables; fix PAL noise period table [hex\_usr] - md: support aborting a Z80 bus wait in order to capture save states without freezing - note that this will violate accuracy; but in practice a slight desync is better than an emulator deadlock - sfc: revert DSP ENDX randomization for now (want to research it more before deploying in an official release) - sfc: fix Super Famicom.sys/manifest.bml APU RAM size [hex\_usr] - tomoko: cleaned up make install rules - hiro/cocoa: use ABGR for pixel data [Sintendo] Note: I forgot to change the command-line and drag-and-drop separator from : to | in this WIP. However, it is corrected in the v103 official binary and source published on download.byuu.org. Sorry about that, I know it makes the Git repository history more difficult. I'm not concerned whether the : → | change is part of v103 or v103r01 in the repository, and will leave this to your discretion, Screwtape. I also still need to set the VDP bit to indicate PAL mode in the Mega Drive core. This is what happens when I have 47 things I have to do, given how lousy my memory is. I miss things.
2017-06-22 06:04:07 +00:00
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 addr, uint comp) -> maybe<uint> {
for(auto& code : codes) {
if(code.addr == addr && (!code.comp || code.comp() == comp)) {
return code.data;
}
}
return nothing;
}
private:
vector<Code> codes;
};
}