Start implementing retro_cheat_set/retro_cheat_reset

This commit is contained in:
twinaphex 2014-12-06 18:13:37 +01:00
parent e83511445b
commit 459c2ffba2
7 changed files with 26 additions and 2 deletions

View File

@ -113,6 +113,8 @@ public:
*/
void setGameShark(const std::string &codes);
void clearCheats();
private:
struct Priv;
Priv *const p_;

View File

@ -188,8 +188,19 @@ bool retro_unserialize(const void *data, size_t size)
return true;
}
void retro_cheat_reset() {}
void retro_cheat_set(unsigned, bool, const char *) {}
void retro_cheat_reset()
{
gb.clearCheats();
}
void retro_cheat_set(unsigned index, bool enabled, const char *code)
{
std::string s = code;
if (s.find("-") != std::string::npos)
gb.setGameGenie(code);
else
gb.setGameShark(code);
}
static std::string basename(std::string filename)

View File

@ -91,6 +91,7 @@ public:
void setGameGenie(const std::string &codes) { memory.setGameGenie(codes); }
void setGameShark(const std::string &codes) { memory.setGameShark(codes); }
void clearCheats() { memory.clearCheats(); }
void display_setColorCorrection(bool enable) { memory.display_setColorCorrection(enable); }
video_pixel_t display_gbcToRgb32(const unsigned bgr15) { return memory.display_gbcToRgb32(bgr15); }

View File

@ -146,6 +146,7 @@ public:
void setDmgPaletteColor(unsigned palNum, unsigned colorNum, unsigned long rgb32);
void setGameGenie(const std::string &codes) { cart.setGameGenie(codes); }
void clearCheats() { cart.clearCheats(); }
void setGameShark(const std::string &codes) { interrupter.setGameShark(codes); }
void display_setColorCorrection(bool enable) { display.setColorCorrection(enable); }

View File

@ -139,5 +139,9 @@ void GB::setGameShark(const std::string &codes) {
p_->cpu.setGameShark(codes);
}
void GB::clearCheats() {
p_->cpu.clearCheats();
}
}

View File

@ -418,6 +418,10 @@ void Cartridge::applyGameGenie(const std::string &code) {
}
}
void Cartridge::clearCheats() {
ggUndoList.clear();
}
void Cartridge::setGameGenie(const std::string &codes) {
//if (loaded()) {
for (std::vector<AddrData>::reverse_iterator it = ggUndoList.rbegin(), end = ggUndoList.rend(); it != end; ++it) {

View File

@ -103,6 +103,7 @@ public:
void setSaveDir(const std::string &dir);
bool loadROM(const void *romdata, unsigned romsize, bool forceDmg, bool multicartCompat);
void setGameGenie(const std::string &codes);
void clearCheats();
void *savedata_ptr()
{