mirror of
https://github.com/devinacker/bsnes-plus.git
synced 2025-04-02 10:52:46 -04:00
improve handling of cheats to handle things other than WRAM (closes #97)
note: mirroring detection for cheats doesn't work for two addresses in the same 64kb bank i.e. the lowest 16 bits of both addresses must still be the same
This commit is contained in:
parent
a5701d2024
commit
e708dc4781
5 changed files with 8 additions and 39 deletions
|
@ -25,13 +25,6 @@ Non-debugging features:
|
|||
- IPS and BPS soft patching
|
||||
- Multiple emulation improvements backported from bsnes/higan (mostly via bsnes-classic)
|
||||
|
||||
## Coming soon
|
||||
|
||||
- On-the-fly ROM saving and reloading from the memory editor for quick hacking and testing
|
||||
- More keyboard shortcuts for menus, etc.
|
||||
- Automatic saving/loading breakpoints between sessions
|
||||
- Similar addressing improvements for cheats
|
||||
|
||||
## Building on Windows
|
||||
|
||||
- Get mingw-w64 (http://mingw-w64.yaxm.org/doku.php/download)
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
bool Cheat::active() const { return cheat_enabled; }
|
||||
bool Cheat::exists(unsigned addr) const { return bitmask[addr >> 3] & 1 << (addr & 7); }
|
||||
bool Cheat::exists(uint16 addr) const { return bitmask[addr >> 3] & 1 << (addr & 7); }
|
||||
|
|
|
@ -25,34 +25,21 @@ void Cheat::synchronize() {
|
|||
for(unsigned n = 0; n < code.addr.size(); n++) {
|
||||
code_enabled = true;
|
||||
|
||||
unsigned addr = mirror(code.addr[n]);
|
||||
uint16 addr = code.addr[n];
|
||||
bitmask[addr >> 3] |= 1 << (addr & 7);
|
||||
if((addr & 0xffe000) == 0x7e0000) {
|
||||
//mirror $7e:0000-1fff to $00-3f|80-bf:0000-1fff
|
||||
unsigned mirroraddr;
|
||||
for(unsigned x = 0; x <= 0x3f; x++) {
|
||||
mirroraddr = ((0x00 + x) << 16) + (addr & 0x1fff);
|
||||
bitmask[mirroraddr >> 3] |= 1 << (mirroraddr & 7);
|
||||
|
||||
mirroraddr = ((0x80 + x) << 16) + (addr & 0x1fff);
|
||||
bitmask[mirroraddr >> 3] |= 1 << (mirroraddr & 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cheat_enabled = system_enabled && code_enabled;
|
||||
}
|
||||
|
||||
bool Cheat::read(unsigned addr, uint8 &data) const {
|
||||
addr = mirror(addr);
|
||||
|
||||
bool Cheat::read(unsigned addr, uint8 &data, Bus &bus) const {
|
||||
for(unsigned i = 0; i < size(); i++) {
|
||||
const CheatCode &code = operator[](i);
|
||||
if(code.enabled == false) continue;
|
||||
|
||||
for(unsigned n = 0; n < code.addr.size(); n++) {
|
||||
if(addr == mirror(code.addr[n])) {
|
||||
if(bus.is_mirror(addr, code.addr[n])) {
|
||||
data = code.data[n];
|
||||
return true;
|
||||
}
|
||||
|
@ -149,16 +136,6 @@ bool Cheat::encode(string &s, unsigned addr, uint8 data, Type type) {
|
|||
}
|
||||
}
|
||||
|
||||
//========
|
||||
//internal
|
||||
//========
|
||||
|
||||
unsigned Cheat::mirror(unsigned addr) const {
|
||||
//$00-3f|80-bf:0000-1fff -> $7e:0000-1fff
|
||||
if((addr & 0x40e000) == 0x000000) return (0x7e0000 + (addr & 0x1fff));
|
||||
return addr;
|
||||
}
|
||||
|
||||
//=========
|
||||
//CheatCode
|
||||
//=========
|
||||
|
|
|
@ -14,10 +14,10 @@ public:
|
|||
bool enabled() const;
|
||||
void enable(bool);
|
||||
void synchronize();
|
||||
bool read(unsigned, uint8&) const;
|
||||
bool read(unsigned, uint8&, Bus&) const;
|
||||
|
||||
inline bool active() const;
|
||||
inline bool exists(unsigned addr) const;
|
||||
inline bool exists(uint16 addr) const;
|
||||
|
||||
Cheat();
|
||||
|
||||
|
@ -25,11 +25,10 @@ public:
|
|||
static bool encode(string&, unsigned, uint8, Type);
|
||||
|
||||
private:
|
||||
uint8 bitmask[0x200000];
|
||||
uint8 bitmask[0x2000];
|
||||
bool system_enabled;
|
||||
bool code_enabled;
|
||||
bool cheat_enabled;
|
||||
unsigned mirror(unsigned) const;
|
||||
};
|
||||
|
||||
extern Cheat cheat;
|
||||
|
|
|
@ -63,7 +63,7 @@ uint8 Bus::read(uint24 addr) {
|
|||
#if defined(CHEAT_SYSTEM)
|
||||
if(cheat.active() && cheat.exists(addr)) {
|
||||
uint8 r;
|
||||
if(cheat.read(addr, r)) return r;
|
||||
if(cheat.read(addr, r, *this)) return r;
|
||||
}
|
||||
#endif
|
||||
Page &p = page[addr >> 8];
|
||||
|
|
Loading…
Add table
Reference in a new issue