| 1 | //============================================================================ |
| 2 | // |
| 3 | // SSSS tt lll lll |
| 4 | // SS SS tt ll ll |
| 5 | // SS tttttt eeee ll ll aaaa |
| 6 | // SSSS tt ee ee ll ll aa |
| 7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" |
| 8 | // SS SS tt ee ll ll aa aa |
| 9 | // SSSS ttt eeeee llll llll aaaaa |
| 10 | // |
| 11 | // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony |
| 12 | // and the Stella Team |
| 13 | // |
| 14 | // See the file "License.txt" for information on usage and redistribution of |
| 15 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 16 | //============================================================================ |
| 17 | |
| 18 | #include "Console.hxx" |
| 19 | #include "System.hxx" |
| 20 | #include "OSystem.hxx" |
| 21 | #include "CheatManager.hxx" |
| 22 | |
| 23 | #include "RamCheat.hxx" |
| 24 | |
| 25 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 26 | RamCheat::RamCheat(OSystem& os, const string& name, const string& code) |
| 27 | : Cheat(os, name, code), |
| 28 | address(uInt16(unhex(myCode.substr(0, 2)))), |
| 29 | value(uInt8(unhex(myCode.substr(2, 2)))) |
| 30 | { |
| 31 | } |
| 32 | |
| 33 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 34 | bool RamCheat::enable() |
| 35 | { |
| 36 | if(!myEnabled) |
| 37 | { |
| 38 | myEnabled = true; |
| 39 | myOSystem.cheat().addPerFrame(name(), code(), myEnabled); |
| 40 | } |
| 41 | return myEnabled; |
| 42 | } |
| 43 | |
| 44 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 45 | bool RamCheat::disable() |
| 46 | { |
| 47 | if(myEnabled) |
| 48 | { |
| 49 | myEnabled = false; |
| 50 | myOSystem.cheat().addPerFrame(name(), code(), myEnabled); |
| 51 | } |
| 52 | return myEnabled; |
| 53 | } |
| 54 | |
| 55 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 56 | void RamCheat::evaluate() |
| 57 | { |
| 58 | myOSystem.console().system().poke(address, value); |
| 59 | } |
| 60 | |