diff options
author | Strangerke | 2016-04-24 20:55:54 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-05-10 09:54:21 +0200 |
commit | 5b0ff520b729fd4c58c800f5c7f64233a5afe8e3 (patch) | |
tree | 41a9a7cc06021a39f9f7edc1bd9ef110d23cc884 /engines | |
parent | f3b59a2dfb96fad1610e9169e5858d66b4ebee80 (diff) | |
download | scummvm-rg350-5b0ff520b729fd4c58c800f5c7f64233a5afe8e3.tar.gz scummvm-rg350-5b0ff520b729fd4c58c800f5c7f64233a5afe8e3.tar.bz2 scummvm-rg350-5b0ff520b729fd4c58c800f5c7f64233a5afe8e3.zip |
GNAP: Refactor scene 49
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gnap/gnap.h | 28 | ||||
-rw-r--r-- | engines/gnap/scenes/scene49.cpp | 304 | ||||
-rw-r--r-- | engines/gnap/scenes/scene49.h | 79 | ||||
-rw-r--r-- | engines/gnap/scenes/scenecore.cpp | 9 |
4 files changed, 240 insertions, 180 deletions
diff --git a/engines/gnap/gnap.h b/engines/gnap/gnap.h index aa8de62de1..5063d90808 100644 --- a/engines/gnap/gnap.h +++ b/engines/gnap/gnap.h @@ -250,17 +250,6 @@ enum { // 0x7AF Gnap walks to the left 1 // 0x7B0 Gnap walks to the left 2 -struct Scene49Obstacle { - int _currSequenceId; - int _closerSequenceId; - int _passedSequenceId; - int _splashSequenceId; - int _collisionSequenceId; - int _prevId; - int _currId; - int _laneNum; -}; - struct Scene51Item { int _currSequenceId; int _droppedSequenceId; @@ -612,23 +601,6 @@ public: bool toyUfoCheckTimer(); void toyUfoFlyTo(int destX, int destY, int minX, int maxX, int minY, int maxY, int animationIndex); - // Scene 49 - int _s49_scoreBarPos, _s49_scoreLevel; - bool _s49_scoreBarFlash; - int _s49_obstacleIndex; - Scene49Obstacle _s49_obstacles[5]; - int _s49_truckSequenceId, _s49_truckId, _s49_truckLaneNum; - int scene49_init(); - void scene49_updateHotspots(); - void scene49_checkObstacles(); - void scene49_updateObstacle(int id); - void scene49_increaseScore(int amount); - void scene49_decreaseScore(int amount); - void scene49_refreshScoreBar(); - void scene49_clearObstacle(int index); - void scene49_run(); - void scene49_updateAnimations(); - // Scene 50 bool _s50_fightDone; int _s50_timesPlayed, _s50_timesPlayedModifier; diff --git a/engines/gnap/scenes/scene49.cpp b/engines/gnap/scenes/scene49.cpp index 2c92919a8b..97a8724072 100644 --- a/engines/gnap/scenes/scene49.cpp +++ b/engines/gnap/scenes/scene49.cpp @@ -23,13 +23,10 @@ #include "gnap/gnap.h" #include "gnap/gamesys.h" #include "gnap/resource.h" +#include "gnap/scenes/scene49.h" namespace Gnap { -struct ObstacleDef { - int sequenceId, ticks; -}; - static const ObstacleDef kObstacleDefs[] = { {0xB4, 15}, {0xCB, 14}, {0xCD, 13}, {0xCF, 15}, {0xBA, 14}, {0xCD, 13}, {0xCF, 12}, {0xCB, 15}, {0xBD, 13}, {0xCF, 12}, @@ -43,36 +40,56 @@ static const ObstacleDef kObstacleDefs[] = { {0xCD, 7}, {0xCB, 7}, {0xCD, 7}, {0xCF, 15}, {0xCF, 15} }; -int GnapEngine::scene49_init() { - _gameSys->setAnimation(0, 0, 0); - _gameSys->setAnimation(0, 0, 1); +Scene49::Scene49(GnapEngine *vm) : Scene(vm) { + _s49_scoreBarFlash = false; + _s49_scoreBarPos = -1; + _s49_scoreLevel = -1; + _s49_obstacleIndex = -1; + _s49_truckSequenceId = -1; + _s49_truckId = -1; + _s49_truckLaneNum = -1; + + for (int i = 0; i < 5; i++) { + _s49_obstacles[i]._currSequenceId = -1; + _s49_obstacles[i]._closerSequenceId = -1; + _s49_obstacles[i]._passedSequenceId = -1; + _s49_obstacles[i]._splashSequenceId = -1; + _s49_obstacles[i]._collisionSequenceId = -1; + _s49_obstacles[i]._prevId = -1; + _s49_obstacles[i]._currId = -1; + _s49_obstacles[i]._laneNum = -1; + } +} + +int Scene49::init() { + _vm->_gameSys->setAnimation(0, 0, 0); + _vm->_gameSys->setAnimation(0, 0, 1); for (int i = 0; i < 5; ++i) - _gameSys->setAnimation(0, 0, i + 2); - _timers[2] = 0; - _timers[0] = 0; - _timers[1] = 0; - clearKeyStatus1(28); - clearKeyStatus1(54); - clearKeyStatus1(52); + _vm->_gameSys->setAnimation(0, 0, i + 2); + _vm->_timers[2] = 0; + _vm->_timers[0] = 0; + _vm->_timers[1] = 0; + _vm->clearKeyStatus1(28); + _vm->clearKeyStatus1(54); + _vm->clearKeyStatus1(52); return 0xD5; } -void GnapEngine::scene49_updateHotspots() { - _hotspotsCount = 0; +void Scene49::updateHotspots() { + _vm->_hotspotsCount = 0; } -void GnapEngine::scene49_checkObstacles() { - - if (_timers[2] == 0) { - - if (_timers[3] == 0) +void Scene49::checkObstacles() { + if (_vm->_timers[2] == 0) { + if (_vm->_timers[3] == 0) { for (int i = 0; i < 5; ++i) - scene49_clearObstacle(i); + clearObstacle(i); + } for (int j = 0; j < 5; ++j) { if (_s49_obstacles[j]._currSequenceId == 0) { - _timers[3] = 35; - _s49_obstacles[j]._currSequenceId = kObstacleDefs[_s49_obstacleIndex].sequenceId; + _vm->_timers[3] = 35; + _s49_obstacles[j]._currSequenceId = kObstacleDefs[_s49_obstacleIndex]._sequenceId; switch (_s49_obstacles[j]._currSequenceId) { case 0xB4: _s49_obstacles[j]._laneNum = 1; @@ -126,9 +143,9 @@ void GnapEngine::scene49_checkObstacles() { } _s49_obstacles[j]._prevId = _s49_truckId; _s49_obstacles[j]._currId = _s49_obstacles[j]._prevId; - _gameSys->setAnimation(_s49_obstacles[j]._currSequenceId, _s49_obstacles[j]._currId, j + 2); - _gameSys->insertSequence(_s49_obstacles[j]._currSequenceId, _s49_obstacles[j]._currId, 0, 0, kSeqNone, 0, 0, -50); - _timers[2] = kObstacleDefs[_s49_obstacleIndex].ticks; + _vm->_gameSys->setAnimation(_s49_obstacles[j]._currSequenceId, _s49_obstacles[j]._currId, j + 2); + _vm->_gameSys->insertSequence(_s49_obstacles[j]._currSequenceId, _s49_obstacles[j]._currId, 0, 0, kSeqNone, 0, 0, -50); + _vm->_timers[2] = kObstacleDefs[_s49_obstacleIndex]._ticks; ++_s49_obstacleIndex; if (_s49_obstacleIndex == 50) _s49_obstacleIndex = 0; @@ -140,12 +157,10 @@ void GnapEngine::scene49_checkObstacles() { } -void GnapEngine::scene49_updateObstacle(int id) { - +void Scene49::updateObstacle(int id) { Scene49Obstacle &obstacle = _s49_obstacles[id]; - obstacle._currId = obstacle._prevId; - + switch (obstacle._laneNum) { case 1: obstacle._prevId = _s49_truckId + 1; @@ -167,39 +182,39 @@ void GnapEngine::scene49_updateObstacle(int id) { if (obstacle._currSequenceId == obstacle._closerSequenceId) { if (_s49_truckLaneNum == obstacle._laneNum) { if (obstacle._splashSequenceId) { - _gameSys->setAnimation(obstacle._collisionSequenceId, obstacle._prevId, id + 2); - _gameSys->insertSequence(obstacle._collisionSequenceId, obstacle._prevId, + _vm->_gameSys->setAnimation(obstacle._collisionSequenceId, obstacle._prevId, id + 2); + _vm->_gameSys->insertSequence(obstacle._collisionSequenceId, obstacle._prevId, obstacle._currSequenceId, obstacle._currId, kSeqSyncWait, 0, 0, -50); obstacle._currSequenceId = obstacle._collisionSequenceId; - playSound(224, false); - scene49_increaseScore(30); + _vm->playSound(224, false); + increaseScore(30); } else if ((obstacle._laneNum == 1 && _s49_truckSequenceId == 0xB0) || (obstacle._laneNum == 2 && (_s49_truckSequenceId == 0xB1 || _s49_truckSequenceId == 0xB2)) || (obstacle._laneNum == 3 && _s49_truckSequenceId == 0xB3)) { - _gameSys->setAnimation(obstacle._passedSequenceId, obstacle._prevId, id + 2); - _gameSys->insertSequence(obstacle._passedSequenceId, obstacle._prevId, + _vm->_gameSys->setAnimation(obstacle._passedSequenceId, obstacle._prevId, id + 2); + _vm->_gameSys->insertSequence(obstacle._passedSequenceId, obstacle._prevId, obstacle._currSequenceId, obstacle._currId, kSeqSyncWait, 0, 0, -50); obstacle._currSequenceId = obstacle._passedSequenceId; } else { - _gameSys->setAnimation(obstacle._collisionSequenceId, 256, 0); - _gameSys->setAnimation(obstacle._passedSequenceId, obstacle._prevId, id + 2); - _gameSys->insertSequence(obstacle._passedSequenceId, obstacle._prevId, + _vm->_gameSys->setAnimation(obstacle._collisionSequenceId, 256, 0); + _vm->_gameSys->setAnimation(obstacle._passedSequenceId, obstacle._prevId, id + 2); + _vm->_gameSys->insertSequence(obstacle._passedSequenceId, obstacle._prevId, obstacle._currSequenceId, obstacle._currId, kSeqSyncWait, 0, 0, -50); - _gameSys->insertSequence(obstacle._collisionSequenceId, 256, + _vm->_gameSys->insertSequence(obstacle._collisionSequenceId, 256, _s49_truckSequenceId, _s49_truckId, kSeqSyncExists, 0, 0, -50); _s49_truckSequenceId = obstacle._collisionSequenceId; _s49_truckId = 256; obstacle._currSequenceId = obstacle._passedSequenceId; - playSound(225, false); - scene49_decreaseScore(30); + _vm->playSound(225, false); + decreaseScore(30); } } else { - _gameSys->setAnimation(obstacle._passedSequenceId, obstacle._prevId, id + 2); - _gameSys->insertSequence(obstacle._passedSequenceId, obstacle._prevId, + _vm->_gameSys->setAnimation(obstacle._passedSequenceId, obstacle._prevId, id + 2); + _vm->_gameSys->insertSequence(obstacle._passedSequenceId, obstacle._prevId, obstacle._currSequenceId, obstacle._currId, kSeqSyncWait, 0, 0, -50); obstacle._currSequenceId = obstacle._passedSequenceId; @@ -207,55 +222,54 @@ void GnapEngine::scene49_updateObstacle(int id) { } else if (obstacle._currSequenceId == obstacle._passedSequenceId) { if (_s49_truckLaneNum == obstacle._laneNum) { if (obstacle._splashSequenceId) { - _gameSys->setAnimation(obstacle._collisionSequenceId, obstacle._prevId, id + 2); - _gameSys->insertSequence(obstacle._collisionSequenceId, obstacle._prevId, + _vm->_gameSys->setAnimation(obstacle._collisionSequenceId, obstacle._prevId, id + 2); + _vm->_gameSys->insertSequence(obstacle._collisionSequenceId, obstacle._prevId, obstacle._currSequenceId, obstacle._currId, kSeqSyncWait, 0, 0, -50); obstacle._currSequenceId = obstacle._collisionSequenceId; - playSound(224, false); - scene49_increaseScore(30); + _vm->playSound(224, false); + increaseScore(30); } } else if (obstacle._splashSequenceId) { - _gameSys->setAnimation(obstacle._splashSequenceId, obstacle._prevId, id + 2); - _gameSys->insertSequence(obstacle._splashSequenceId, obstacle._prevId, + _vm->_gameSys->setAnimation(obstacle._splashSequenceId, obstacle._prevId, id + 2); + _vm->_gameSys->insertSequence(obstacle._splashSequenceId, obstacle._prevId, obstacle._currSequenceId, obstacle._currId, kSeqSyncWait, 0, 0, -50); obstacle._currSequenceId = obstacle._splashSequenceId; } } else { - _gameSys->setAnimation(0, 0, id + 2); - scene49_clearObstacle(id); + _vm->_gameSys->setAnimation(0, 0, id + 2); + clearObstacle(id); } - } -void GnapEngine::scene49_increaseScore(int amount) { +void Scene49::increaseScore(int amount) { if (_s49_scoreBarPos + amount <= 556) { _s49_scoreBarPos += amount; - _gameSys->fillSurface(0, _s49_scoreBarPos, 508, amount, 22, 255, 0, 0); + _vm->_gameSys->fillSurface(0, _s49_scoreBarPos, 508, amount, 22, 255, 0, 0); } _s49_scoreLevel = _s49_scoreBarPos + amount >= 556; } -void GnapEngine::scene49_decreaseScore(int amount) { +void Scene49::decreaseScore(int amount) { if (_s49_scoreBarPos >= 226 && _s49_scoreLevel == 0) { if (_s49_scoreBarFlash) - scene49_refreshScoreBar(); - _gameSys->fillSurface(0, _s49_scoreBarPos, 508, amount, 22, 89, 0, 5); + refreshScoreBar(); + _vm->_gameSys->fillSurface(0, _s49_scoreBarPos, 508, amount, 22, 89, 0, 5); _s49_scoreBarPos -= amount; _s49_scoreLevel = 0; } } -void GnapEngine::scene49_refreshScoreBar() { +void Scene49::refreshScoreBar() { if (_s49_scoreBarFlash) - _gameSys->fillSurface(0, 226, 508, 330, 22, 255, 0, 0); + _vm->_gameSys->fillSurface(0, 226, 508, 330, 22, 255, 0, 0); else - _gameSys->fillSurface(0, 226, 508, 330, 22, 89, 0, 5); + _vm->_gameSys->fillSurface(0, 226, 508, 330, 22, 89, 0, 5); _s49_scoreBarFlash = !_s49_scoreBarFlash; } -void GnapEngine::scene49_clearObstacle(int index) { +void Scene49::clearObstacle(int index) { _s49_obstacles[index]._currSequenceId = 0; _s49_obstacles[index]._closerSequenceId = 0; _s49_obstacles[index]._passedSequenceId = 0; @@ -266,8 +280,7 @@ void GnapEngine::scene49_clearObstacle(int index) { _s49_obstacles[index]._laneNum = 0; } -void GnapEngine::scene49_run() { - +void Scene49::run() { bool animToggle6 = false; bool animToggle5 = false; bool animToggle4 = false; @@ -275,17 +288,17 @@ void GnapEngine::scene49_run() { bool streetAnimToggle = false; bool bgAnimToggle = false; - playSound(0xE2, true); - setSoundVolume(0xE2, 75); + _vm->playSound(0xE2, true); + _vm->setSoundVolume(0xE2, 75); - hideCursor(); - setGrabCursorSprite(-1); + _vm->hideCursor(); + _vm->setGrabCursorSprite(-1); _s49_scoreBarPos = 196; _s49_scoreLevel = 0; _s49_scoreBarFlash = false; - switch (getRandom(3)) { + switch (_vm->getRandom(3)) { case 0: _s49_truckSequenceId = 0xAD; _s49_truckLaneNum = 1; @@ -300,50 +313,49 @@ void GnapEngine::scene49_run() { break; } - int bgWidth1 = _gameSys->getSpriteWidthById(0x5E); + int bgWidth1 = _vm->_gameSys->getSpriteWidthById(0x5E); int bgX1 = 600; - int bgWidth2 = _gameSys->getSpriteWidthById(0x5F); + int bgWidth2 = _vm->_gameSys->getSpriteWidthById(0x5F); int bgX2 = 400; - int bgWidth3 = _gameSys->getSpriteWidthById(4); + int bgWidth3 = _vm->_gameSys->getSpriteWidthById(4); int bgX3 = 700; - int bgWidth4 = _gameSys->getSpriteWidthById(5); + int bgWidth4 = _vm->_gameSys->getSpriteWidthById(5); int bgX4 = 500; - int bgWidth5 = _gameSys->getSpriteWidthById(6); + int bgWidth5 = _vm->_gameSys->getSpriteWidthById(6); int bgX5 = 300; - int bgWidth6 = _gameSys->getSpriteWidthById(7); + int bgWidth6 = _vm->_gameSys->getSpriteWidthById(7); int bgX6 = 100; - _gameSys->setAnimation(0xC8, 251, 1); - _gameSys->setAnimation(_s49_truckSequenceId, 256, 0); - _gameSys->insertSequence(0xC9, 256, 0, 0, kSeqNone, 0, 600, 85); - _gameSys->insertSequence(0xCA, 257, 0, 0, kSeqNone, 0, 400, 100); - _gameSys->insertSequence(0xC4, 256, 0, 0, kSeqNone, 0, 700, 140); - _gameSys->insertSequence(0xC5, 257, 0, 0, kSeqNone, 0, 500, 160); - _gameSys->insertSequence(0xC6, 258, 0, 0, kSeqNone, 0, 300, 140); - _gameSys->insertSequence(0xC7, 259, 0, 0, kSeqNone, 0, 100, 140); - _gameSys->insertSequence(0xC8, 251, 0, 0, kSeqNone, 0, 0, -50); - _gameSys->insertSequence(_s49_truckSequenceId, 256, 0, 0, kSeqNone, 0, 0, -50); + _vm->_gameSys->setAnimation(0xC8, 251, 1); + _vm->_gameSys->setAnimation(_s49_truckSequenceId, 256, 0); + _vm->_gameSys->insertSequence(0xC9, 256, 0, 0, kSeqNone, 0, 600, 85); + _vm->_gameSys->insertSequence(0xCA, 257, 0, 0, kSeqNone, 0, 400, 100); + _vm->_gameSys->insertSequence(0xC4, 256, 0, 0, kSeqNone, 0, 700, 140); + _vm->_gameSys->insertSequence(0xC5, 257, 0, 0, kSeqNone, 0, 500, 160); + _vm->_gameSys->insertSequence(0xC6, 258, 0, 0, kSeqNone, 0, 300, 140); + _vm->_gameSys->insertSequence(0xC7, 259, 0, 0, kSeqNone, 0, 100, 140); + _vm->_gameSys->insertSequence(0xC8, 251, 0, 0, kSeqNone, 0, 0, -50); + _vm->_gameSys->insertSequence(_s49_truckSequenceId, 256, 0, 0, kSeqNone, 0, 0, -50); - _timers[0] = 2; + _vm->_timers[0] = 2; for (int i = 0; i < 5; ++i) - scene49_clearObstacle(i); + clearObstacle(i); _s49_obstacleIndex = 0; - _timers[2] = getRandom(20) + 10; + _vm->_timers[2] = _vm->getRandom(20) + 10; _s49_truckId = 256; - _timers[3] = 35; + _vm->_timers[3] = 35; - while (!_sceneDone) { - - if (_timers[0] == 0) { + while (!_vm->_sceneDone) { + if (_vm->_timers[0] == 0) { // Update background animations (clouds etc.) --bgX1; bgX2 -= 2; @@ -364,24 +376,24 @@ void GnapEngine::scene49_run() { if (bgX6 <= -bgWidth6) bgX6 = 799; bgAnimToggle = !bgAnimToggle; - _gameSys->insertSequence(0xC9, (bgAnimToggle ? 1 : 0) + 256, 0xC9, (bgAnimToggle ? 0 : 1) + 256, kSeqSyncWait, 0, bgX1, 85); - _gameSys->insertSequence(0xCA, (bgAnimToggle ? 1 : 0) + 257, 0xCA, (bgAnimToggle ? 0 : 1) + 257, kSeqSyncWait, 0, bgX2, 100); - _gameSys->insertSequence(0xC4, (bgAnimToggle ? 1 : 0) + 256, 0xC4, (bgAnimToggle ? 0 : 1) + 256, kSeqSyncWait, 0, bgX3, 140); - _gameSys->insertSequence(0xC5, (bgAnimToggle ? 1 : 0) + 257, 0xC5, (bgAnimToggle ? 0 : 1) + 257, kSeqSyncWait, 0, bgX4, 160); - _gameSys->insertSequence(0xC6, (bgAnimToggle ? 1 : 0) + 258, 0xC6, (bgAnimToggle ? 0 : 1) + 258, kSeqSyncWait, 0, bgX5, 140); - _gameSys->insertSequence(0xC7, (bgAnimToggle ? 1 : 0) + 259, 0xC7, (bgAnimToggle ? 0 : 1) + 259, kSeqSyncWait, 0, bgX6, 140); - _timers[0] = 2; + _vm->_gameSys->insertSequence(0xC9, (bgAnimToggle ? 1 : 0) + 256, 0xC9, (bgAnimToggle ? 0 : 1) + 256, kSeqSyncWait, 0, bgX1, 85); + _vm->_gameSys->insertSequence(0xCA, (bgAnimToggle ? 1 : 0) + 257, 0xCA, (bgAnimToggle ? 0 : 1) + 257, kSeqSyncWait, 0, bgX2, 100); + _vm->_gameSys->insertSequence(0xC4, (bgAnimToggle ? 1 : 0) + 256, 0xC4, (bgAnimToggle ? 0 : 1) + 256, kSeqSyncWait, 0, bgX3, 140); + _vm->_gameSys->insertSequence(0xC5, (bgAnimToggle ? 1 : 0) + 257, 0xC5, (bgAnimToggle ? 0 : 1) + 257, kSeqSyncWait, 0, bgX4, 160); + _vm->_gameSys->insertSequence(0xC6, (bgAnimToggle ? 1 : 0) + 258, 0xC6, (bgAnimToggle ? 0 : 1) + 258, kSeqSyncWait, 0, bgX5, 140); + _vm->_gameSys->insertSequence(0xC7, (bgAnimToggle ? 1 : 0) + 259, 0xC7, (bgAnimToggle ? 0 : 1) + 259, kSeqSyncWait, 0, bgX6, 140); + _vm->_timers[0] = 2; } - if (_gameSys->getAnimationStatus(1) == 2) { + if (_vm->_gameSys->getAnimationStatus(1) == 2) { streetAnimToggle = !streetAnimToggle; - _gameSys->setAnimation(0xC8, (streetAnimToggle ? 1 : 0) + 251, 1); - _gameSys->insertSequence(0xC8, (streetAnimToggle ? 1 : 0) + 251, 200, (streetAnimToggle ? 0 : 1) + 251, kSeqSyncWait, 0, 0, -50); + _vm->_gameSys->setAnimation(0xC8, (streetAnimToggle ? 1 : 0) + 251, 1); + _vm->_gameSys->insertSequence(0xC8, (streetAnimToggle ? 1 : 0) + 251, 200, (streetAnimToggle ? 0 : 1) + 251, kSeqSyncWait, 0, 0, -50); } - scene49_checkObstacles(); + checkObstacles(); - if (_gameSys->getAnimationStatus(0) == 2) { + if (_vm->_gameSys->getAnimationStatus(0) == 2) { switch (_s49_truckSequenceId) { case 0xB1: _s49_truckLaneNum = 1; @@ -396,26 +408,26 @@ void GnapEngine::scene49_run() { } animToggle3 = !animToggle3; if (_s49_truckLaneNum == 1) { - _gameSys->setAnimation(0xAD, (animToggle3 ? 1 : 0) + 256, 0); - _gameSys->insertSequence(0xAD, (animToggle3 ? 1 : 0) + 256, _s49_truckSequenceId, _s49_truckId, kSeqSyncWait, 0, 0, -50); + _vm->_gameSys->setAnimation(0xAD, (animToggle3 ? 1 : 0) + 256, 0); + _vm->_gameSys->insertSequence(0xAD, (animToggle3 ? 1 : 0) + 256, _s49_truckSequenceId, _s49_truckId, kSeqSyncWait, 0, 0, -50); _s49_truckSequenceId = 0xAD; } else if (_s49_truckLaneNum == 2) { - _gameSys->setAnimation(0xAE, (animToggle3 ? 1 : 0) + 256, 0); - _gameSys->insertSequence(0xAE, (animToggle3 ? 1 : 0) + 256, _s49_truckSequenceId, _s49_truckId, kSeqSyncWait, 0, 0, -50); + _vm->_gameSys->setAnimation(0xAE, (animToggle3 ? 1 : 0) + 256, 0); + _vm->_gameSys->insertSequence(0xAE, (animToggle3 ? 1 : 0) + 256, _s49_truckSequenceId, _s49_truckId, kSeqSyncWait, 0, 0, -50); _s49_truckSequenceId = 0xAE; } else { - _gameSys->setAnimation(0xAF, (animToggle3 ? 1 : 0) + 256, 0); - _gameSys->insertSequence(0xAF, (animToggle3 ? 1 : 0) + 256, _s49_truckSequenceId, _s49_truckId, kSeqSyncWait, 0, 0, -50); + _vm->_gameSys->setAnimation(0xAF, (animToggle3 ? 1 : 0) + 256, 0); + _vm->_gameSys->insertSequence(0xAF, (animToggle3 ? 1 : 0) + 256, _s49_truckSequenceId, _s49_truckId, kSeqSyncWait, 0, 0, -50); _s49_truckSequenceId = 0xAF; } _s49_truckId = (animToggle3 ? 1 : 0) + 256; if (_s49_scoreLevel == 1) { - if (!_gameSys->isSequenceActive(0xD4, 266)) { - _gameSys->setAnimation(0xD4, 266, 8); - _gameSys->insertSequence(0xD4, 266, 0, 0, kSeqNone, 0, 0, -50); + if (!_vm->_gameSys->isSequenceActive(0xD4, 266)) { + _vm->_gameSys->setAnimation(0xD4, 266, 8); + _vm->_gameSys->insertSequence(0xD4, 266, 0, 0, kSeqNone, 0, 0, -50); } ++_s49_scoreLevel; - _timers[1] = 2; + _vm->_timers[1] = 2; animToggle4 = false; animToggle5 = false; animToggle6 = false; @@ -423,13 +435,13 @@ void GnapEngine::scene49_run() { } } - if (_s49_scoreLevel != 0 && !_timers[1]) { - scene49_refreshScoreBar(); - _timers[1] = 8; + if (_s49_scoreLevel != 0 && !_vm->_timers[1]) { + refreshScoreBar(); + _vm->_timers[1] = 8; if (animToggle6) { if (animToggle5) { - if (animToggle4 && !_gameSys->isSequenceActive(212, 266)) - _gameSys->insertSequence(212, 266, 0, 0, kSeqNone, 0, 0, -50); + if (animToggle4 && !_vm->_gameSys->isSequenceActive(212, 266)) + _vm->_gameSys->insertSequence(212, 266, 0, 0, kSeqNone, 0, 0, -50); animToggle4 = !animToggle4; } animToggle5 = !animToggle5; @@ -437,15 +449,15 @@ void GnapEngine::scene49_run() { animToggle6 = !animToggle6; } - scene49_updateAnimations(); + updateAnimations(); - if (sceneXX_sub_4466B1()) { - _sceneDone = true; - _newSceneNum = 2; - _newCursorValue = 1; + if (_vm->sceneXX_sub_4466B1()) { + _vm->_sceneDone = true; + _vm->_newSceneNum = 2; + _vm->_newCursorValue = 1; } - if (isKeyStatus1(Common::KEYCODE_RIGHT)) { + if (_vm->isKeyStatus1(Common::KEYCODE_RIGHT)) { // Steer right if (_s49_truckSequenceId == 0xB3) _s49_truckLaneNum = 2; @@ -453,22 +465,22 @@ void GnapEngine::scene49_run() { _s49_truckLaneNum = 1; if (_s49_truckLaneNum != 3 && _s49_truckLaneNum != 2) { if (_s49_scoreLevel) { - _sceneDone = true; - _newSceneNum = 47; + _vm->_sceneDone = true; + _vm->_newSceneNum = 47; } } else { int steerSequenceId = (_s49_truckLaneNum == 3) ? 0xB3 : 0xB1; if (_s49_truckSequenceId == 0xAE || _s49_truckSequenceId == 0xAF) { - _gameSys->setAnimation(steerSequenceId, 256, 0); - _gameSys->insertSequence(steerSequenceId, 256, _s49_truckSequenceId, _s49_truckId, kSeqSyncExists, 0, 0, -50); + _vm->_gameSys->setAnimation(steerSequenceId, 256, 0); + _vm->_gameSys->insertSequence(steerSequenceId, 256, _s49_truckSequenceId, _s49_truckId, kSeqSyncExists, 0, 0, -50); _s49_truckSequenceId = steerSequenceId; _s49_truckId = 256; } } - clearKeyStatus1(Common::KEYCODE_RIGHT); + _vm->clearKeyStatus1(Common::KEYCODE_RIGHT); } - if (isKeyStatus1(Common::KEYCODE_LEFT)) { + if (_vm->isKeyStatus1(Common::KEYCODE_LEFT)) { // Steer left if (_s49_truckSequenceId == 0xB0) _s49_truckLaneNum = 2; @@ -477,37 +489,31 @@ void GnapEngine::scene49_run() { if (_s49_truckLaneNum == 1 || _s49_truckLaneNum == 2) { int steerSequenceId = (_s49_truckLaneNum == 1) ? 0xB0 : 0xB2; if (_s49_truckSequenceId == 0xAD || _s49_truckSequenceId == 0xAE) { - _gameSys->setAnimation(steerSequenceId, 256, 0); - _gameSys->insertSequence(steerSequenceId, 256, _s49_truckSequenceId, _s49_truckId, kSeqSyncExists, 0, 0, -50); + _vm->_gameSys->setAnimation(steerSequenceId, 256, 0); + _vm->_gameSys->insertSequence(steerSequenceId, 256, _s49_truckSequenceId, _s49_truckId, kSeqSyncExists, 0, 0, -50); _s49_truckSequenceId = steerSequenceId; _s49_truckId = 256; } } - clearKeyStatus1(Common::KEYCODE_LEFT); + _vm->clearKeyStatus1(Common::KEYCODE_LEFT); } - - gameUpdateTick(); - + _vm->gameUpdateTick(); } - - stopSound(0xE2); - + _vm->stopSound(0xE2); } -void GnapEngine::scene49_updateAnimations() { - +void Scene49::updateAnimations() { for (int i = 0; i < 5; ++i) { - if (_gameSys->getAnimationStatus(i + 2) == 2) { + if (_vm->_gameSys->getAnimationStatus(i + 2) == 2) { if (_s49_obstacles[i]._currSequenceId) - scene49_updateObstacle(i); + updateObstacle(i); } } - if (_gameSys->getAnimationStatus(8) == 2) { - _sceneDone = true; - _newSceneNum = 47; + if (_vm->_gameSys->getAnimationStatus(8) == 2) { + _vm->_sceneDone = true; + _vm->_newSceneNum = 47; } - } } // End of namespace Gnap diff --git a/engines/gnap/scenes/scene49.h b/engines/gnap/scenes/scene49.h new file mode 100644 index 0000000000..f44b2ed25b --- /dev/null +++ b/engines/gnap/scenes/scene49.h @@ -0,0 +1,79 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GNAP_SCENE49_H +#define GNAP_SCENE49_H + +#include "gnap/debugger.h" +#include "gnap/scenes/scenecore.h" + +namespace Gnap { + +class GnapEngine; + +struct Scene49Obstacle { + int _currSequenceId; + int _closerSequenceId; + int _passedSequenceId; + int _splashSequenceId; + int _collisionSequenceId; + int _prevId; + int _currId; + int _laneNum; +}; + +struct ObstacleDef { + int _sequenceId; + int _ticks; +}; + +class Scene49: public Scene { +public: + Scene49(GnapEngine *vm); + ~Scene49() {} + + virtual int init(); + virtual void updateHotspots(); + virtual void run(); + virtual void updateAnimations(); + virtual void updateAnimationsCb() {}; + +private: + int _s49_scoreBarPos; + int _s49_scoreLevel; + bool _s49_scoreBarFlash; + int _s49_obstacleIndex; + Scene49Obstacle _s49_obstacles[5]; + int _s49_truckSequenceId; + int _s49_truckId; + int _s49_truckLaneNum; + + void checkObstacles(); + void updateObstacle(int id); + void increaseScore(int amount); + void decreaseScore(int amount); + void refreshScoreBar(); + void clearObstacle(int index); +}; + +} // End of namespace Gnap +#endif // GNAP_SCENE49_H diff --git a/engines/gnap/scenes/scenecore.cpp b/engines/gnap/scenes/scenecore.cpp index 8c22cc8703..a4d7604b0f 100644 --- a/engines/gnap/scenes/scenecore.cpp +++ b/engines/gnap/scenes/scenecore.cpp @@ -70,6 +70,7 @@ #include "gnap/scenes/scene46.h" #include "gnap/scenes/scene47.h" #include "gnap/scenes/scene48.h" +#include "gnap/scenes/scene49.h" #include "gnap/scenes/scene54.h" namespace Gnap { @@ -404,8 +405,9 @@ int GnapEngine::initSceneLogic() { initSceneGrid(21, 146, 11, 10); break; case 49: - backgroundId = scene49_init(); - scene49_updateHotspots(); + _scene = new Scene49(this); + backgroundId = _scene->init(); + _scene->updateHotspots(); _gameSys->setScaleValues(0, 500, 1, 1000); initSceneGrid(21, 146, 11, 10); break; @@ -768,7 +770,8 @@ void GnapEngine::runSceneLogic() { delete _scene; break; case 49: - scene49_run(); + _scene = new Scene48(this); + _scene->init(); if (_newSceneNum == 55) _newSceneNum = 47; break; |