aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorTorbjörn Andersson2012-10-06 00:01:47 +0200
committerTorbjörn Andersson2012-10-06 00:01:47 +0200
commit49e96aa188bbb8ed3820d5d3e057beb7632485d3 (patch)
tree5693ba32455fd4c77968282dcce62a0171c36571 /engines
parentbe918da34864a4555be25995b511df98539284a3 (diff)
downloadscummvm-rg350-49e96aa188bbb8ed3820d5d3e057beb7632485d3.tar.gz
scummvm-rg350-49e96aa188bbb8ed3820d5d3e057beb7632485d3.tar.bz2
scummvm-rg350-49e96aa188bbb8ed3820d5d3e057beb7632485d3.zip
TOLTECS: Improve the shake screen effects during movies
I don't know how often the original shook the screen (perhaps as often as it could?), but at least we now have the opportunity to shake the screen more than once per movie frame.
Diffstat (limited to 'engines')
-rw-r--r--engines/toltecs/movie.cpp11
-rw-r--r--engines/toltecs/screen.cpp11
-rw-r--r--engines/toltecs/screen.h3
3 files changed, 17 insertions, 8 deletions
diff --git a/engines/toltecs/movie.cpp b/engines/toltecs/movie.cpp
index 44b52b113a..35accb5d93 100644
--- a/engines/toltecs/movie.cpp
+++ b/engines/toltecs/movie.cpp
@@ -125,11 +125,7 @@ void MoviePlayer::playMovie(uint resIndex) {
case kChunkFirstImage:
case kChunkSubsequentImages:
unpackRle(chunkBuffer, _vm->_screen->_backScreen);
- // TODO: Rework this
- _vm->_screen->updateShakeScreen();
_vm->_screen->_fullRefresh = true;
- _vm->updateInput();
- _vm->drawScreen();
_soundChunkFramesLeft--;
if (_soundChunkFramesLeft <= _framesPerSoundChunk) {
@@ -137,7 +133,12 @@ void MoviePlayer::playMovie(uint resIndex) {
}
while (_vm->_mixer->getSoundElapsedTime(_audioStreamHandle) < (1000 * frame) / 9) {
- g_system->delayMillis(10);
+ if (_vm->_screen->_shakeActive && _vm->_screen->updateShakeScreen()) {
+ _vm->_screen->_fullRefresh = true;
+ }
+ _vm->updateInput();
+ _vm->drawScreen();
+ // Note: drawScreen() calls delayMillis()
}
frame++;
diff --git a/engines/toltecs/screen.cpp b/engines/toltecs/screen.cpp
index 32202ad13e..c8d6740b02 100644
--- a/engines/toltecs/screen.cpp
+++ b/engines/toltecs/screen.cpp
@@ -43,9 +43,11 @@ Screen::Screen(ToltecsEngine *vm) : _vm(vm) {
// Screen shaking
_shakeActive = false;
+ _shakeTime = 0;
_shakeCounterInit = 0;
_shakeCounter = 0;
_shakePos = 0;
+ _shakeTime = 0;
// Verb line
_verbLineNum = 0;
@@ -156,6 +158,7 @@ void Screen::drawGuiImage(int16 x, int16 y, uint resIndex) {
void Screen::startShakeScreen(int16 shakeCounter) {
_shakeActive = true;
+ _shakeTime = 0;
_shakeCounterInit = shakeCounter;
_shakeCounter = shakeCounter;
_shakePos = 0;
@@ -166,15 +169,19 @@ void Screen::stopShakeScreen() {
_vm->_system->setShakePos(0);
}
-void Screen::updateShakeScreen() {
- if (_shakeActive) {
+bool Screen::updateShakeScreen() {
+ // Assume shaking happens no more often than 50 times per second
+ if (_shakeActive && _vm->_system->getMillis() - _shakeTime >= 20) {
+ _shakeTime = _vm->_system->getMillis();
_shakeCounter--;
if (_shakeCounter == 0) {
_shakeCounter = _shakeCounterInit;
_shakePos ^= 8;
_vm->_system->setShakePos(_shakePos);
+ return true;
}
}
+ return false;
}
void Screen::addStaticSprite(byte *spriteItem) {
diff --git a/engines/toltecs/screen.h b/engines/toltecs/screen.h
index 315e9a45c3..788cde50c6 100644
--- a/engines/toltecs/screen.h
+++ b/engines/toltecs/screen.h
@@ -161,7 +161,7 @@ public:
void startShakeScreen(int16 shakeCounter);
void stopShakeScreen();
- void updateShakeScreen();
+ bool updateShakeScreen();
// Sprite list
void addStaticSprite(byte *spriteItem);
@@ -221,6 +221,7 @@ public:
// Screen shaking
bool _shakeActive;
+ uint32 _shakeTime;
int16 _shakeCounterInit, _shakeCounter;
int _shakePos;