CheatCodeDialog is semi-functional

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@794 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
urchlay 2005-09-25 20:18:46 +00:00
parent c917e2ee93
commit 8f035f8e3f
8 changed files with 25 additions and 21 deletions

View File

@ -20,14 +20,14 @@ uInt16 Cheat::unhex(string hex) {
return ret;
}
Cheat* Cheat::parse(string code) {
Cheat* Cheat::parse(OSystem *osystem, string code) {
for(unsigned int i=0; i<code.size(); i++)
if(!isxdigit(code[i]))
return 0;
switch(code.size()) {
case 6:
return new CheetahCheat(code);
return new CheetahCheat(osystem, code);
default:
return 0;

View File

@ -3,10 +3,11 @@
#define CHEAT_HXX
#include "bspf.hxx"
#include "OSystem.hxx"
class Cheat {
public:
static Cheat *parse(string code);
static Cheat *parse(OSystem *osystem, string code);
static uInt16 unhex(string hex);
virtual ~Cheat();

View File

@ -3,7 +3,8 @@
//#include "Debugger.hxx"
#include "CheetahCheat.hxx"
CheetahCheat::CheetahCheat(string code) {
CheetahCheat::CheetahCheat(OSystem *os, string code) {
myOSystem = os;
_enabled = false;
address = 0xf000 + unhex(code.substr(0, 3));
@ -17,20 +18,16 @@ CheetahCheat::~CheetahCheat() {
bool CheetahCheat::enabled() { return _enabled; }
bool CheetahCheat::enable() {
/* FIXME
for(int i=0; i<count; i++) {
savedRom[i] = Debugger::debugger().peek(address + i);
Debugger::debugger().patchROM(address + i, value);
savedRom[i] = myOSystem->console().cartridge().peek(address + i);
myOSystem->console().cartridge().patch(address + i, value);
}
*/
return _enabled = true;
}
bool CheetahCheat::disable() {
/* FIXME
for(int i=0; i<count; i++) {
Debugger::debugger().patchROM(address + i, savedRom[i]);
myOSystem->console().cartridge().patch(address + i, savedRom[i]);
}
*/
return _enabled = false;
}

View File

@ -2,11 +2,12 @@
#ifndef CHEETAH_CHEAT_HXX
#define CHEETAH_CHEAT_HXX
#include "OSystem.hxx"
#include "Cheat.hxx"
class CheetahCheat : public Cheat {
public:
CheetahCheat(string code);
CheetahCheat(OSystem *os, string code);
~CheetahCheat();
virtual bool enabled();
@ -20,6 +21,7 @@ class CheetahCheat : public Cheat {
uInt16 address;
uInt8 value;
uInt8 count;
OSystem *myOSystem;
};
#endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Debugger.hxx,v 1.77 2005-09-23 17:38:26 stephena Exp $
// $Id: Debugger.hxx,v 1.78 2005-09-25 20:18:46 urchlay Exp $
//============================================================================
#ifndef DEBUGGER_HXX
@ -79,7 +79,7 @@ typedef uInt16 (Debugger::*DEBUGGER_WORD_METHOD)();
for all debugging operations in Stella (parser, 6502 debugger, etc).
@author Stephen Anthony
@version $Id: Debugger.hxx,v 1.77 2005-09-23 17:38:26 stephena Exp $
@version $Id: Debugger.hxx,v 1.78 2005-09-25 20:18:46 urchlay Exp $
*/
class Debugger : public DialogContainer
{
@ -99,6 +99,8 @@ class Debugger : public DialogContainer
virtual ~Debugger();
public:
OSystem *getOSystem() { return myOSystem; }
/**
Updates the basedialog to be of the type defined for this derived class.
*/

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DebuggerParser.cxx,v 1.81 2005-09-25 18:35:26 urchlay Exp $
// $Id: DebuggerParser.cxx,v 1.82 2005-09-25 20:18:46 urchlay Exp $
//============================================================================
#include "bspf.hxx"
@ -1369,7 +1369,7 @@ void DebuggerParser::executeCheetah() {
for(int arg = 0; arg < argCount; arg++) {
string& cheat = argStrings[arg];
Cheat *c = Cheat::parse(cheat);
Cheat *c = Cheat::parse(debugger->getOSystem(), cheat);
if(c) {
c->enable();
commandResult = "Cheetah code " + cheat + " enabled\n";

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TIA.cxx,v 1.60 2005-09-25 18:35:26 urchlay Exp $
// $Id: TIA.cxx,v 1.61 2005-09-25 20:18:46 urchlay Exp $
//============================================================================
#include <cassert>
@ -522,7 +522,6 @@ void TIA::update()
myFrameGreyed = true;
} else {
endFrame();
myFrameGreyed = false;
}
}
@ -571,6 +570,8 @@ inline void TIA::startFrame() {
myCOLUBK &= 0xfefefefe;
}
}
myFrameGreyed = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -581,6 +582,8 @@ inline void TIA::endFrame() {
// Stats counters
myFrameCounter++;
myFrameGreyed = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -589,7 +592,6 @@ void TIA::updateScanline()
// Start a new frame if the old one was finished
if(!myPartialFrameFlag) {
startFrame();
myFrameGreyed = false;
}
// grey out old frame contents

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CheatCodeDialog.cxx,v 1.3 2005-09-25 18:35:26 urchlay Exp $
// $Id: CheatCodeDialog.cxx,v 1.4 2005-09-25 20:18:46 urchlay Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -61,7 +61,7 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
{
case kEditAcceptCmd:
cerr << myInput->getEditString() << endl;
myCheat = Cheat::parse(myInput->getEditString());
myCheat = Cheat::parse(instance(), myInput->getEditString());
if(myCheat) {
myError->setFlags(WIDGET_INVISIBLE);
loadConfig();