From 6496482de5884b71fa3d263725c4f0ab41ef32d3 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Wed, 3 Jan 2007 07:36:44 +0000 Subject: Added experimental "fast mode" for Broken Sword 2. (Use Ctrl-f to toggle.) svn-id: r24970 --- engines/sword2/render.cpp | 7 +++---- engines/sword2/sound.cpp | 2 +- engines/sword2/sword2.cpp | 15 +++++++++++++++ engines/sword2/sword2.h | 3 +++ 4 files changed, 22 insertions(+), 5 deletions(-) (limited to 'engines/sword2') diff --git a/engines/sword2/render.cpp b/engines/sword2/render.cpp index 24130af5c6..02f576c99c 100644 --- a/engines/sword2/render.cpp +++ b/engines/sword2/render.cpp @@ -31,7 +31,6 @@ namespace Sword2 { -#define MILLISECSPERCYCLE 83 #define RENDERAVERAGETOTAL 4 void Screen::updateRect(Common::Rect *r) { @@ -297,7 +296,7 @@ void Screen::renderParallax(byte *ptr, int16 l) { void Screen::initialiseRenderCycle() { _initialTime = _vm->_system->getMillis(); - _totalTime = _initialTime + MILLISECSPERCYCLE; + _totalTime = _initialTime + (1000 / _vm->getFramesPerSecond()); } /** @@ -354,7 +353,7 @@ bool Screen::endRenderCycle() { } if (_startTime + _renderAverageTime >= _totalTime) { - _totalTime += MILLISECSPERCYCLE; + _totalTime += (1000 / _vm->getFramesPerSecond()); _initialTime = time; return true; } @@ -365,7 +364,7 @@ bool Screen::endRenderCycle() { // rest of the render cycle. _vm->sleepUntil(_totalTime); _initialTime = _vm->_system->getMillis(); - _totalTime += MILLISECSPERCYCLE; + _totalTime += (1000 / _vm->getFramesPerSecond()); return true; } #endif diff --git a/engines/sword2/sound.cpp b/engines/sword2/sound.cpp index e62fac5e0a..5beff2772d 100644 --- a/engines/sword2/sound.cpp +++ b/engines/sword2/sound.cpp @@ -219,7 +219,7 @@ void Sound::queueFx(int32 res, int32 type, int32 delay, int32 volume, int32 pan) // effects, however, it's the average number of // seconds between playing the sound, so we // have to multiply by the frame rate. - delay *= 12; + delay *= _vm->getFramesPerSecond(); } volume = (volume * Audio::Mixer::kMaxChannelVolume) / 16; diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp index 778dfb1ab5..544c55e00a 100644 --- a/engines/sword2/sword2.cpp +++ b/engines/sword2/sword2.cpp @@ -42,6 +42,8 @@ #include "sword2/screen.h" #include "sword2/sound.h" +#define FRAMES_PER_SECOND 12 + namespace Sword2 { struct GameSettings { @@ -175,6 +177,7 @@ Sword2Engine::Sword2Engine(OSystem *syst) : Engine(syst) { _graphicsLevelFudged = false; _gameCycle = 0; + _gameSpeed = 1; _quit = false; } @@ -227,6 +230,10 @@ void Sword2Engine::writeSettings() { ConfMan.flushToDisk(); } +int Sword2Engine::getFramesPerSecond() { + return _gameSpeed * FRAMES_PER_SECOND; +} + /** * The global script variables and player object should be kept open throughout * the game, so that they are never expelled by the resource manager. @@ -513,6 +520,14 @@ void Sword2Engine::parseInputEvents() { while (_system->pollEvent(event)) { switch (event.type) { case OSystem::EVENT_KEYDOWN: + if (event.kbd.flags == OSystem::KBD_CTRL) { + if (event.kbd.keycode == 'f') { + if (_gameSpeed == 1) + _gameSpeed = 2; + else + _gameSpeed = 1; + } + } if (!(_inputEventFilter & RD_KEYDOWN)) { _keyboardEvent.pending = true; _keyboardEvent.repeat = now + 400; diff --git a/engines/sword2/sword2.h b/engines/sword2/sword2.h index df66a2cb5e..4e7de99833 100644 --- a/engines/sword2/sword2.h +++ b/engines/sword2/sword2.h @@ -116,6 +116,7 @@ private: uint32 _startRes; bool _useSubtitles; + int _gameSpeed; StartUp _startList[MAX_starts]; @@ -125,6 +126,8 @@ public: int go(); int init(); + int getFramesPerSecond(); + void registerDefaultSettings(); void readSettings(); void writeSettings(); -- cgit v1.2.3