DREAMWEB: added setSpeed, CTRL-F shortcut and removed erik's comment because it's good idea :)

This commit is contained in:
Vladimir Menshakov 2011-06-13 11:35:58 +04:00 committed by Alyssa Milburn
parent 92a11ea59d
commit 308fcf0953
2 changed files with 21 additions and 4 deletions

View File

@ -66,6 +66,7 @@ DreamWebEngine::DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gam
DebugMan.addDebugChannel(kDebugSaveLoad, "SaveLoad", "Track Save/Load Function");
_outSaveFile = 0;
_inSaveFile = 0;
_speed = 1;
}
DreamWebEngine::~DreamWebEngine() {
@ -73,10 +74,6 @@ DreamWebEngine::~DreamWebEngine() {
delete _console;
}
// Let's see if it's a good idea to emulate VSYNC interrupts with a timer like
// this. There's a chance we'll miss interrupts, which could be countered by
// counting them instead of just flagging them, but we'll see...
static void vSyncInterrupt(void *refCon) {
DreamWebEngine *vm = (DreamWebEngine *)refCon;
@ -126,6 +123,15 @@ void DreamWebEngine::processEvents() {
keyHandled = true;
}
break;
case Common::KEYCODE_f:
if (event.kbd.flags & Common::KBD_CTRL) {
if (_speed != 10)
setSpeed(10);
else
setSpeed(1);
keyHandled = true;
}
break;
default:
break;
}
@ -166,6 +172,13 @@ Common::Error DreamWebEngine::run() {
return Common::kNoError;
}
void DreamWebEngine::setSpeed(uint speed) {
debug(0, "setting speed %u", speed);
_speed = speed;
getTimerManager()->removeTimerProc(vSyncInterrupt);
getTimerManager()->installTimerProc(vSyncInterrupt, 1000000 / 70 / speed, this);
}
void DreamWebEngine::openFile(const Common::String &name) {
processEvents();
closeFile();

View File

@ -104,6 +104,8 @@ private:
void keyPressed(uint16 ascii);
void setSpeed(uint speed);
const DreamWebGameDescription *_gameDescription;
Common::RandomSource _rnd;
@ -111,6 +113,8 @@ private:
Common::OutSaveFile *_outSaveFile;
Common::InSaveFile *_inSaveFile;
uint _speed;
dreamgen::Context _context;
};