aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2016-04-24 21:40:42 +0200
committerEugene Sandulenko2016-05-10 09:54:21 +0200
commitaca5984e2b2f08890f828bbe9c331841c9b33674 (patch)
tree3192596019880f69c53c7b82f7a84a198ed258f5 /engines
parent5b0ff520b729fd4c58c800f5c7f64233a5afe8e3 (diff)
downloadscummvm-rg350-aca5984e2b2f08890f828bbe9c331841c9b33674.tar.gz
scummvm-rg350-aca5984e2b2f08890f828bbe9c331841c9b33674.tar.bz2
scummvm-rg350-aca5984e2b2f08890f828bbe9c331841c9b33674.zip
GNAP: Refactor scene 50
Diffstat (limited to 'engines')
-rw-r--r--engines/gnap/gnap.cpp9
-rw-r--r--engines/gnap/gnap.h33
-rw-r--r--engines/gnap/scenes/scene50.cpp341
-rw-r--r--engines/gnap/scenes/scene50.h87
-rw-r--r--engines/gnap/scenes/scenecore.cpp11
5 files changed, 274 insertions, 207 deletions
diff --git a/engines/gnap/gnap.cpp b/engines/gnap/gnap.cpp
index 2ef75164ba..5d4e8106ab 100644
--- a/engines/gnap/gnap.cpp
+++ b/engines/gnap/gnap.cpp
@@ -2021,15 +2021,6 @@ void GnapEngine::initGlobalSceneVars() {
// Shared by scenes 17 && 18
_s18_garbageCanPos = 8;
- // Scene 50
- _s50_timesPlayed = 0;
- _s50_timesPlayedModifier = 0;
- _s50_attackCounter = 0;
- _s50_leftTongueEnergyBarPos = 10;
- _s50_leftTongueNextIdCtr = 0;
- _s50_rightTongueEnergyBarPos = 10;
- _s50_rightTongueNextIdCtr = 0;
-
// Scene 52
_s52_gameScore = 0;
_s52_aliensInitialized = false;
diff --git a/engines/gnap/gnap.h b/engines/gnap/gnap.h
index 5063d90808..bd1714dbbe 100644
--- a/engines/gnap/gnap.h
+++ b/engines/gnap/gnap.h
@@ -601,39 +601,6 @@ public:
bool toyUfoCheckTimer();
void toyUfoFlyTo(int destX, int destY, int minX, int maxX, int minY, int maxY, int animationIndex);
- // Scene 50
- bool _s50_fightDone;
- int _s50_timesPlayed, _s50_timesPlayedModifier;
- int _s50_attackCounter;
- int _s50_roundNum, _s50_timeRemaining;
- int _s50_leftTongueRoundsWon, _s50_rightTongueRoundsWon;
- int _s50_leftTongueEnergyBarPos, _s50_rightTongueEnergyBarPos;
- int _s50_leftTongueSequenceId, _s50_leftTongueId;
- int _s50_leftTongueNextSequenceId, _s50_leftTongueNextId, _s50_leftTongueNextIdCtr;
- int _s50_rightTongueSequenceId, _s50_rightTongueId;
- int _s50_rightTongueNextSequenceId, _s50_rightTongueNextId, _s50_rightTongueNextIdCtr;
- int _s50_leftTongueEnergy, _s50_rightTongueEnergy;
- int scene50_init();
- void scene50_updateHotspots();
- bool scene50_tongueWinsRound(int tongueNum);
- void scene50_playWinAnim(int tongueNum, bool fightOver);
- void scene50_delayTicks();
- void scene50_initRound();
- bool scene50_updateCountdown();
- void scene50_drawCountdown(int value);
- void scene50_playTonguesIdle();
- void scene50_playRoundAnim(int roundNum);
- bool scene50_updateEnergyBars(int newLeftBarPos, int newRightBarPos);
- void scene50_waitForAnim(int animationIndex);
- int scene50_checkInput();
- int scene50_getRightTongueAction();
- void scene50_updateAnimations();
- int scene50_getRightTongueActionTicks();
- int scene50_getLeftTongueNextId();
- int scene50_getRightTongueNextId();
- void scene50_playWinBadgeAnim(int tongueNum);
- void scene50_run();
-
// Scene 51
int _s51_cashAmount;
int _s51_digits[4];
diff --git a/engines/gnap/scenes/scene50.cpp b/engines/gnap/scenes/scene50.cpp
index 2ec842af7a..68f29f3d78 100644
--- a/engines/gnap/scenes/scene50.cpp
+++ b/engines/gnap/scenes/scene50.cpp
@@ -23,128 +23,156 @@
#include "gnap/gnap.h"
#include "gnap/gamesys.h"
#include "gnap/resource.h"
+#include "gnap/scenes/scene50.h"
namespace Gnap {
-int GnapEngine::scene50_init() {
+Scene50::Scene50(GnapEngine *vm) : Scene(vm) {
+ _s50_fightDone = false;
+
+ _s50_roundNum = -1;
+ _s50_timeRemaining = -1;
+ _s50_leftTongueRoundsWon = -1;
+ _s50_rightTongueRoundsWon = -1;
+ _s50_leftTongueSequenceId = -1;
+ _s50_leftTongueId = -1;
+ _s50_leftTongueNextSequenceId = -1;
+ _s50_leftTongueNextId = -1;
+ _s50_rightTongueSequenceId = -1;
+ _s50_rightTongueId = -1;
+ _s50_rightTongueNextSequenceId = -1;
+ _s50_rightTongueNextId = -1;
+ _s50_leftTongueEnergy = -1;
+ _s50_rightTongueEnergy = -1;
+
+ _s50_timesPlayed = 0;
+ _s50_timesPlayedModifier = 0;
+ _s50_attackCounter = 0;
+ _s50_leftTongueEnergyBarPos = 10;
+ _s50_leftTongueNextIdCtr = 0;
+ _s50_rightTongueEnergyBarPos = 10;
+ _s50_rightTongueNextIdCtr = 0;
+}
+
+int Scene50::init() {
return 0xC7;
}
-void GnapEngine::scene50_updateHotspots() {
- _hotspotsCount = 0;
+void Scene50::updateHotspots() {
+ _vm->_hotspotsCount = 0;
}
-bool GnapEngine::scene50_tongueWinsRound(int tongueNum) {
+bool Scene50::tongueWinsRound(int tongueNum) {
if (tongueNum == 1)
++_s50_leftTongueRoundsWon;
else
++_s50_rightTongueRoundsWon;
- scene50_playWinBadgeAnim(tongueNum);
+ playWinBadgeAnim(tongueNum);
bool fightOver = _s50_rightTongueRoundsWon == 2 || _s50_leftTongueRoundsWon == 2;
- scene50_playWinAnim(tongueNum, fightOver);
+ playWinAnim(tongueNum, fightOver);
return fightOver;
}
-void GnapEngine::scene50_playWinAnim(int tongueNum, bool fightOver) {
+void Scene50::playWinAnim(int tongueNum, bool fightOver) {
if (tongueNum == 1) {
if (fightOver) {
- _gameSys->insertSequence(0xAD, 140, 0xAC, 140, kSeqSyncWait, 0, 0, 0);
- _gameSys->insertSequence(0xB4, 100, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
- _gameSys->insertSequence(0xBD, 100, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncWait, 0, 0, 0);
- _gameSys->insertSequence(0xBC, 100, 0xBD, 100, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xAD, 140, 0xAC, 140, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xB4, 100, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xBD, 100, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xBC, 100, 0xBD, 100, kSeqSyncWait, 0, 0, 0);
_s50_leftTongueSequenceId = 0xB4;
_s50_rightTongueSequenceId = 0xBC;
_s50_rightTongueId = 100;
_s50_leftTongueId = 100;
- _gameSys->setAnimation(0xB4, 100, 6);
- _gameSys->setAnimation(_s50_rightTongueSequenceId, 100, 5);
- scene50_waitForAnim(6);
- scene50_waitForAnim(5);
- invAdd(kItemGum);
- setFlag(kGFUnk13);
+ _vm->_gameSys->setAnimation(0xB4, 100, 6);
+ _vm->_gameSys->setAnimation(_s50_rightTongueSequenceId, 100, 5);
+ waitForAnim(6);
+ waitForAnim(5);
+ _vm->invAdd(kItemGum);
+ _vm->setFlag(kGFUnk13);
} else {
- _gameSys->insertSequence(0xB4, 100, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
- _gameSys->insertSequence(0xBD, 100, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncWait, 0, 0, 0);
- _gameSys->insertSequence(0xBC, 100, 0xBD, 100, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xB4, 100, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xBD, 100, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xBC, 100, 0xBD, 100, kSeqSyncWait, 0, 0, 0);
_s50_leftTongueSequenceId = 0xB4;
_s50_rightTongueSequenceId = 0xBC;
_s50_rightTongueId = 100;
_s50_leftTongueId = 100;
- _gameSys->setAnimation(0xB4, 100, 6);
- _gameSys->setAnimation(_s50_rightTongueSequenceId, 100, 5);
- scene50_waitForAnim(6);
- scene50_waitForAnim(5);
+ _vm->_gameSys->setAnimation(0xB4, 100, 6);
+ _vm->_gameSys->setAnimation(_s50_rightTongueSequenceId, 100, 5);
+ waitForAnim(6);
+ waitForAnim(5);
}
} else {
- _gameSys->insertSequence(0xBE, 100, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncWait, 0, 0, 0);
- _gameSys->setAnimation(0xBE, 100, 5);
- scene50_waitForAnim(5);
- _gameSys->insertSequence(0xBF, 100, 0xBE, 100, kSeqSyncWait, 0, 0, 0);
- _gameSys->insertSequence(0xB5, 100, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xBE, 100, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->setAnimation(0xBE, 100, 5);
+ waitForAnim(5);
+ _vm->_gameSys->insertSequence(0xBF, 100, 0xBE, 100, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xB5, 100, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
_s50_rightTongueSequenceId = 0xBF;
_s50_leftTongueSequenceId = 0xB5;
_s50_rightTongueId = 100;
_s50_leftTongueId = 100;
- _gameSys->setAnimation(0xB5, 100, 6);
- _gameSys->setAnimation(_s50_rightTongueSequenceId, 100, 5);
- scene50_waitForAnim(6);
- scene50_waitForAnim(5);
+ _vm->_gameSys->setAnimation(0xB5, 100, 6);
+ _vm->_gameSys->setAnimation(_s50_rightTongueSequenceId, 100, 5);
+ waitForAnim(6);
+ waitForAnim(5);
}
// TODO delayTicksA(1, 7);
}
-void GnapEngine::scene50_delayTicks() {
+void Scene50::delayTicks() {
// TODO delayTicksA(3, 7);
}
-void GnapEngine::scene50_initRound() {
+void Scene50::initRound() {
_s50_leftTongueEnergy = 10;
_s50_rightTongueEnergy = 10;
_s50_fightDone = false;
- _timers[3] = scene50_getRightTongueActionTicks();
- _timers[4] = 0;
- _timers[6] = 0;
- _gameSys->fillSurface(0, 91, 73, 260, 30, 212, 0, 0);
- _gameSys->fillSurface(0, 450, 73, 260, 30, 212, 0, 0);
+ _vm->_timers[3] = getRightTongueActionTicks();
+ _vm->_timers[4] = 0;
+ _vm->_timers[6] = 0;
+ _vm->_gameSys->fillSurface(0, 91, 73, 260, 30, 212, 0, 0);
+ _vm->_gameSys->fillSurface(0, 450, 73, 260, 30, 212, 0, 0);
_s50_timeRemaining = 40;
- scene50_drawCountdown(40);
+ drawCountdown(40);
}
-bool GnapEngine::scene50_updateCountdown() {
- if (!_timers[5]) {
+bool Scene50::updateCountdown() {
+ if (!_vm->_timers[5]) {
--_s50_timeRemaining;
if (_s50_timeRemaining < 0) {
return true;
} else {
- _timers[5] = 15;
- scene50_drawCountdown(_s50_timeRemaining);
+ _vm->_timers[5] = 15;
+ drawCountdown(_s50_timeRemaining);
}
}
return false;
}
-void GnapEngine::scene50_drawCountdown(int value) {
+void Scene50::drawCountdown(int value) {
char str[8];
sprintf(str, "%02d", value);
- _gameSys->fillSurface(0, 371, 505, 50, 27, 0, 0, 0);
- _gameSys->drawTextToSurface(0, 381, 504, 255, 255, 255, str);
+ _vm->_gameSys->fillSurface(0, 371, 505, 50, 27, 0, 0, 0);
+ _vm->_gameSys->drawTextToSurface(0, 381, 504, 255, 255, 255, str);
}
-void GnapEngine::scene50_playTonguesIdle() {
- _gameSys->insertSequence(0xBA, 100, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
- _gameSys->insertSequence(0xC2, 100, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncWait, 0, 0, 0);
+void Scene50::playTonguesIdle() {
+ _vm->_gameSys->insertSequence(0xBA, 100, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xC2, 100, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncWait, 0, 0, 0);
_s50_leftTongueSequenceId = 0xBA;
_s50_rightTongueSequenceId = 0xC2;
_s50_rightTongueNextSequenceId = -1;
_s50_leftTongueNextSequenceId = -1;
_s50_leftTongueId = 100;
_s50_rightTongueId = 100;
- _gameSys->setAnimation(0xC2, 100, 5);
- _gameSys->setAnimation(_s50_leftTongueSequenceId, _s50_leftTongueId, 6);
+ _vm->_gameSys->setAnimation(0xC2, 100, 5);
+ _vm->_gameSys->setAnimation(_s50_leftTongueSequenceId, _s50_leftTongueId, 6);
}
-void GnapEngine::scene50_playRoundAnim(int roundNum) {
- int sequenceId;
+void Scene50::playRoundAnim(int roundNum) {
+ int sequenceId = 0;
switch (roundNum) {
case 1:
@@ -158,23 +186,21 @@ void GnapEngine::scene50_playRoundAnim(int roundNum) {
break;
}
- _gameSys->insertSequence(sequenceId, 256, 0, 0, kSeqNone, 0, 0, 0);
- _gameSys->setAnimation(sequenceId, 256, 7);
- scene50_waitForAnim(7);
-
- _gameSys->insertSequence(0xAB, 256, sequenceId, 256, kSeqSyncWait, 0, 0, 0);
- _gameSys->setAnimation(0xAB, 256, 7);
- scene50_waitForAnim(7);
+ _vm->_gameSys->insertSequence(sequenceId, 256, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->_gameSys->setAnimation(sequenceId, 256, 7);
+ waitForAnim(7);
+ _vm->_gameSys->insertSequence(0xAB, 256, sequenceId, 256, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->setAnimation(0xAB, 256, 7);
+ waitForAnim(7);
}
-bool GnapEngine::scene50_updateEnergyBars(int newLeftBarPos, int newRightBarPos) {
-
+bool Scene50::updateEnergyBars(int newLeftBarPos, int newRightBarPos) {
if (newLeftBarPos != _s50_leftTongueEnergyBarPos) {
if (newLeftBarPos < 0)
newLeftBarPos = 0;
_s50_leftTongueEnergyBarPos = newLeftBarPos;
- _gameSys->fillSurface(0, 26 * newLeftBarPos + 91, 73, 260 - 26 * newLeftBarPos, 30, 0, 0, 0);
+ _vm->_gameSys->fillSurface(0, 26 * newLeftBarPos + 91, 73, 260 - 26 * newLeftBarPos, 30, 0, 0, 0);
}
if (newRightBarPos != _s50_rightTongueEnergyBarPos) {
@@ -182,7 +208,7 @@ bool GnapEngine::scene50_updateEnergyBars(int newLeftBarPos, int newRightBarPos)
newRightBarPos = 0;
_s50_rightTongueEnergyBarPos = newRightBarPos;
if (newRightBarPos != 10)
- _gameSys->fillSurface(0, 26 * (9 - newRightBarPos) + 450, 73, 26, 30, 0, 0, 0);
+ _vm->_gameSys->fillSurface(0, 26 * (9 - newRightBarPos) + 450, 73, 26, 30, 0, 0, 0);
}
if (newLeftBarPos * newRightBarPos > 0)
@@ -193,37 +219,37 @@ bool GnapEngine::scene50_updateEnergyBars(int newLeftBarPos, int newRightBarPos)
return true;
}
-void GnapEngine::scene50_waitForAnim(int animationIndex) {
- while (_gameSys->getAnimationStatus(animationIndex) != 2) {
- gameUpdateTick();
+void Scene50::waitForAnim(int animationIndex) {
+ while (_vm->_gameSys->getAnimationStatus(animationIndex) != 2) {
+ _vm->gameUpdateTick();
}
- _gameSys->setAnimation(0, 0, animationIndex);
+ _vm->_gameSys->setAnimation(0, 0, animationIndex);
}
-int GnapEngine::scene50_checkInput() {
+int Scene50::checkInput() {
int sequenceId = -1;
- if (isKeyStatus1(Common::KEYCODE_RIGHT)) {
- clearKeyStatus1(Common::KEYCODE_RIGHT);
+ if (_vm->isKeyStatus1(Common::KEYCODE_RIGHT)) {
+ _vm->clearKeyStatus1(Common::KEYCODE_RIGHT);
sequenceId = 0xB6;
- } else if (isKeyStatus1(Common::KEYCODE_LEFT)) {
- clearKeyStatus1(Common::KEYCODE_LEFT);
+ } else if (_vm->isKeyStatus1(Common::KEYCODE_LEFT)) {
+ _vm->clearKeyStatus1(Common::KEYCODE_LEFT);
sequenceId = 0xB3;
- } else if (isKeyStatus1(Common::KEYCODE_ESCAPE)) {
- clearKeyStatus1(Common::KEYCODE_ESCAPE);
+ } else if (_vm->isKeyStatus1(Common::KEYCODE_ESCAPE)) {
+ _vm->clearKeyStatus1(Common::KEYCODE_ESCAPE);
_s50_fightDone = true;
}
return sequenceId;
}
-int GnapEngine::scene50_getRightTongueAction() {
+int Scene50::getRightTongueAction() {
int sequenceId = -1;
- if (!_timers[3]) {
- _timers[3] = scene50_getRightTongueActionTicks();
+ if (!_vm->_timers[3]) {
+ _vm->_timers[3] = getRightTongueActionTicks();
if (_s50_rightTongueEnergy >= _s50_leftTongueEnergy) {
- switch (getRandom(5)) {
+ switch (_vm->getRandom(5)) {
case 0:
sequenceId = 0xBE;
break;
@@ -241,7 +267,7 @@ int GnapEngine::scene50_getRightTongueAction() {
break;
}
} else {
- switch (getRandom(4)) {
+ switch (_vm->getRandom(4)) {
case 0:
sequenceId = 0xBE;
break;
@@ -261,12 +287,11 @@ int GnapEngine::scene50_getRightTongueAction() {
return sequenceId;
}
-void GnapEngine::scene50_updateAnimations() {
-
- if (!_timers[4])
+void Scene50::updateAnimations() {
+ if (!_vm->_timers[4])
_s50_attackCounter = 0;
- if (_gameSys->getAnimationStatus(5) == 2) {
+ if (_vm->_gameSys->getAnimationStatus(5) == 2) {
if (_s50_rightTongueSequenceId == 0xBE) {
if (_s50_leftTongueSequenceId != 0xB3 && _s50_leftTongueSequenceId != 0xB8)
_s50_rightTongueNextSequenceId = 0xBF;
@@ -276,38 +301,38 @@ void GnapEngine::scene50_updateAnimations() {
if (_s50_rightTongueNextSequenceId == -1)
_s50_rightTongueNextSequenceId = 0xC2;
if (_s50_rightTongueNextSequenceId == 0xBF) {
- _s50_leftTongueNextId = scene50_getLeftTongueNextId();
- _s50_rightTongueNextId = scene50_getRightTongueNextId();
- _gameSys->setAnimation(_s50_rightTongueNextSequenceId, _s50_rightTongueNextId, 5);
- _gameSys->setAnimation(0xB9, _s50_leftTongueNextId, 6);
- _gameSys->insertSequence(_s50_rightTongueNextSequenceId, _s50_rightTongueNextId, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncWait, 0, 0, 0);
- _gameSys->insertSequence(0xB9, _s50_leftTongueNextId, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncExists, 0, 0, 0);
+ _s50_leftTongueNextId = getLeftTongueNextId();
+ _s50_rightTongueNextId = getRightTongueNextId();
+ _vm->_gameSys->setAnimation(_s50_rightTongueNextSequenceId, _s50_rightTongueNextId, 5);
+ _vm->_gameSys->setAnimation(0xB9, _s50_leftTongueNextId, 6);
+ _vm->_gameSys->insertSequence(_s50_rightTongueNextSequenceId, _s50_rightTongueNextId, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xB9, _s50_leftTongueNextId, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncExists, 0, 0, 0);
_s50_rightTongueSequenceId = _s50_rightTongueNextSequenceId;
_s50_rightTongueNextSequenceId = -1;
_s50_leftTongueSequenceId = 0xB9;
_s50_leftTongueNextSequenceId = -1;
_s50_rightTongueId = _s50_rightTongueNextId;
_s50_leftTongueId = _s50_leftTongueNextId;
- _s50_leftTongueEnergy -= getRandom(2) + 1;//CHECKME
+ _s50_leftTongueEnergy -= _vm->getRandom(2) + 1;//CHECKME
} else {
- _s50_rightTongueNextId = scene50_getRightTongueNextId();
- _gameSys->setAnimation(_s50_rightTongueNextSequenceId, _s50_rightTongueNextId, 5);
- _gameSys->insertSequence(_s50_rightTongueNextSequenceId, _s50_rightTongueNextId, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncWait, 0, 0, 0);
+ _s50_rightTongueNextId = getRightTongueNextId();
+ _vm->_gameSys->setAnimation(_s50_rightTongueNextSequenceId, _s50_rightTongueNextId, 5);
+ _vm->_gameSys->insertSequence(_s50_rightTongueNextSequenceId, _s50_rightTongueNextId, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncWait, 0, 0, 0);
_s50_rightTongueSequenceId = _s50_rightTongueNextSequenceId;
_s50_rightTongueNextSequenceId = -1;
_s50_rightTongueId = _s50_rightTongueNextId;
}
}
- if (_gameSys->getAnimationStatus(6) == 2) {
+ if (_vm->_gameSys->getAnimationStatus(6) == 2) {
if (_s50_leftTongueSequenceId == 0xB6) {
++_s50_attackCounter;
if (_s50_timesPlayedModifier + 3 <= _s50_attackCounter) {
_s50_leftTongueNextSequenceId = 0xB8;
} else {
- _timers[4] = 20;
+ _vm->_timers[4] = 20;
//CHECKME
- if (_s50_rightTongueSequenceId != 0xBB && _s50_rightTongueSequenceId != 0xC0 && getRandom(8) != _s50_roundNum)
+ if (_s50_rightTongueSequenceId != 0xBB && _s50_rightTongueSequenceId != 0xC0 && _vm->getRandom(8) != _s50_roundNum)
_s50_leftTongueNextSequenceId = 0xB7;
else
_s50_leftTongueNextSequenceId = 0xB8;
@@ -318,12 +343,12 @@ void GnapEngine::scene50_updateAnimations() {
if (_s50_leftTongueNextSequenceId == -1)
_s50_leftTongueNextSequenceId = 0xBA;
if (_s50_leftTongueNextSequenceId == 0xB7) {
- _s50_leftTongueNextId = scene50_getLeftTongueNextId();
- _s50_rightTongueNextId = scene50_getRightTongueNextId();
- _gameSys->setAnimation(_s50_leftTongueNextSequenceId, _s50_leftTongueNextId, 6);
- _gameSys->setAnimation(0xC1, _s50_rightTongueNextId, 5);
- _gameSys->insertSequence(_s50_leftTongueNextSequenceId, _s50_leftTongueNextId, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
- _gameSys->insertSequence(0xC1, _s50_rightTongueNextId, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncExists, 0, 0, 0);
+ _s50_leftTongueNextId = getLeftTongueNextId();
+ _s50_rightTongueNextId = getRightTongueNextId();
+ _vm->_gameSys->setAnimation(_s50_leftTongueNextSequenceId, _s50_leftTongueNextId, 6);
+ _vm->_gameSys->setAnimation(0xC1, _s50_rightTongueNextId, 5);
+ _vm->_gameSys->insertSequence(_s50_leftTongueNextSequenceId, _s50_leftTongueNextId, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xC1, _s50_rightTongueNextId, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncExists, 0, 0, 0);
_s50_leftTongueSequenceId = _s50_leftTongueNextSequenceId;
_s50_leftTongueNextSequenceId = -1;
_s50_rightTongueSequenceId = 0xC1;
@@ -332,19 +357,19 @@ void GnapEngine::scene50_updateAnimations() {
_s50_leftTongueId = _s50_leftTongueNextId;
--_s50_rightTongueEnergy;
} else if (_s50_leftTongueNextSequenceId != 0xB8 || _s50_rightTongueSequenceId != 0xC2) {
- _s50_leftTongueNextId = scene50_getLeftTongueNextId();
- _gameSys->setAnimation(_s50_leftTongueNextSequenceId, _s50_leftTongueNextId, 6);
- _gameSys->insertSequence(_s50_leftTongueNextSequenceId, _s50_leftTongueNextId, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
+ _s50_leftTongueNextId = getLeftTongueNextId();
+ _vm->_gameSys->setAnimation(_s50_leftTongueNextSequenceId, _s50_leftTongueNextId, 6);
+ _vm->_gameSys->insertSequence(_s50_leftTongueNextSequenceId, _s50_leftTongueNextId, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
_s50_leftTongueSequenceId = _s50_leftTongueNextSequenceId;
_s50_leftTongueNextSequenceId = -1;
_s50_leftTongueId = _s50_leftTongueNextId;
} else {
- _s50_leftTongueNextId = scene50_getLeftTongueNextId();
- _s50_rightTongueNextId = scene50_getRightTongueNextId();
- _gameSys->setAnimation(0xBB, _s50_rightTongueNextId, 5);
- _gameSys->setAnimation(_s50_leftTongueNextSequenceId, _s50_leftTongueNextId, 6);
- _gameSys->insertSequence(_s50_leftTongueNextSequenceId, _s50_leftTongueNextId, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
- _gameSys->insertSequence(0xBB, _s50_rightTongueNextId, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncExists, 0, 0, 0);
+ _s50_leftTongueNextId = getLeftTongueNextId();
+ _s50_rightTongueNextId = getRightTongueNextId();
+ _vm->_gameSys->setAnimation(0xBB, _s50_rightTongueNextId, 5);
+ _vm->_gameSys->setAnimation(_s50_leftTongueNextSequenceId, _s50_leftTongueNextId, 6);
+ _vm->_gameSys->insertSequence(_s50_leftTongueNextSequenceId, _s50_leftTongueNextId, _s50_leftTongueSequenceId, _s50_leftTongueId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xBB, _s50_rightTongueNextId, _s50_rightTongueSequenceId, _s50_rightTongueId, kSeqSyncExists, 0, 0, 0);
_s50_rightTongueSequenceId = 0xBB;
_s50_rightTongueId = _s50_rightTongueNextId;
_s50_rightTongueNextSequenceId = -1;
@@ -353,24 +378,23 @@ void GnapEngine::scene50_updateAnimations() {
_s50_leftTongueId = _s50_leftTongueNextId;
}
}
-
}
-int GnapEngine::scene50_getRightTongueActionTicks() {
+int Scene50::getRightTongueActionTicks() {
return 15 - 5 * _s50_roundNum + 1;
}
-int GnapEngine::scene50_getLeftTongueNextId() {
+int Scene50::getLeftTongueNextId() {
_s50_leftTongueNextIdCtr = (_s50_leftTongueNextIdCtr + 1) % 3;
return _s50_leftTongueNextIdCtr + 100;
}
-int GnapEngine::scene50_getRightTongueNextId() {
+int Scene50::getRightTongueNextId() {
_s50_rightTongueNextIdCtr = (_s50_rightTongueNextIdCtr + 1) % 3;
return _s50_rightTongueNextIdCtr + 100;
}
-void GnapEngine::scene50_playWinBadgeAnim(int tongueNum) {
+void Scene50::playWinBadgeAnim(int tongueNum) {
int sequenceId;
if (tongueNum == 1) {
@@ -385,19 +409,17 @@ void GnapEngine::scene50_playWinBadgeAnim(int tongueNum) {
sequenceId = 0xC6;
}
- _gameSys->setAnimation(sequenceId, 120, 7);
- _gameSys->insertSequence(sequenceId, 120, 0, 0, kSeqNone, 0, 0, 0);
- scene50_waitForAnim(7);
-
+ _vm->_gameSys->setAnimation(sequenceId, 120, 7);
+ _vm->_gameSys->insertSequence(sequenceId, 120, 0, 0, kSeqNone, 0, 0, 0);
+ waitForAnim(7);
}
-void GnapEngine::scene50_run() {
-
+void Scene50::run() {
++_s50_timesPlayed;
_s50_timesPlayedModifier = _s50_timesPlayed / 4;
_s50_leftTongueRoundsWon = 0;
_s50_rightTongueRoundsWon = 0;
- // scene50_initFont();
+ // initFont();
_s50_leftTongueSequenceId = 186;
_s50_rightTongueSequenceId = 194;
_s50_rightTongueNextSequenceId = -1;
@@ -405,75 +427,72 @@ void GnapEngine::scene50_run() {
_s50_leftTongueId = 100;
_s50_rightTongueId = 100;
- _gameSys->setAnimation(194, 100, 5);
- _gameSys->setAnimation(_s50_leftTongueSequenceId, _s50_leftTongueId, 6);
- _gameSys->insertSequence(_s50_leftTongueSequenceId, _s50_leftTongueId, 0, 0, kSeqNone, 0, 0, 0);
- _gameSys->insertSequence(_s50_rightTongueSequenceId, _s50_rightTongueId, 0, 0, kSeqNone, 0, 0, 0);
- _gameSys->insertSequence(172, 140, 0, 0, kSeqNone, 0, 0, 0);
- endSceneInit();
+ _vm->_gameSys->setAnimation(194, 100, 5);
+ _vm->_gameSys->setAnimation(_s50_leftTongueSequenceId, _s50_leftTongueId, 6);
+ _vm->_gameSys->insertSequence(_s50_leftTongueSequenceId, _s50_leftTongueId, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->_gameSys->insertSequence(_s50_rightTongueSequenceId, _s50_rightTongueId, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->_gameSys->insertSequence(172, 140, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->endSceneInit();
- scene50_initRound();
+ initRound();
_s50_roundNum = 1;
- setGrabCursorSprite(-1);
- hideCursor();
+ _vm->setGrabCursorSprite(-1);
+ _vm->hideCursor();
// TODO delayTicksA(1, 7);
- scene50_playRoundAnim(_s50_roundNum);
+ playRoundAnim(_s50_roundNum);
- _timers[5] = 15;
+ _vm->_timers[5] = 15;
while (!_s50_fightDone) {
-
/* TODO
if (sceneXX_sub_4466B1())
_s50_fightDone = true;
*/
- int playerSequenceId = scene50_checkInput();
+ int playerSequenceId = checkInput();
if (playerSequenceId != -1)
_s50_leftTongueNextSequenceId = playerSequenceId;
- int rightSequenceId = scene50_getRightTongueAction();
+ int rightSequenceId = getRightTongueAction();
if (rightSequenceId != -1)
_s50_rightTongueNextSequenceId = rightSequenceId;
- scene50_updateAnimations();
+ updateAnimations();
- if (scene50_updateCountdown() ||
- scene50_updateEnergyBars(_s50_leftTongueEnergy, _s50_rightTongueEnergy)) {
- int v0;
+ if (updateCountdown() ||
+ updateEnergyBars(_s50_leftTongueEnergy, _s50_rightTongueEnergy)) {
+ bool v0;
if (_s50_rightTongueEnergy < _s50_leftTongueEnergy)
- v0 = scene50_tongueWinsRound(1);
+ v0 = tongueWinsRound(1);
else
- v0 = scene50_tongueWinsRound(2);
+ v0 = tongueWinsRound(2);
if (v0) {
- scene50_delayTicks();
+ delayTicks();
_s50_fightDone = true;
} else {
++_s50_roundNum;
- scene50_initRound();
- scene50_playTonguesIdle();
- scene50_updateEnergyBars(_s50_leftTongueEnergy, _s50_rightTongueEnergy);
- scene50_playRoundAnim(_s50_roundNum);
- _timers[5] = 15;
+ initRound();
+ playTonguesIdle();
+ updateEnergyBars(_s50_leftTongueEnergy, _s50_rightTongueEnergy);
+ playRoundAnim(_s50_roundNum);
+ _vm->_timers[5] = 15;
}
}
-
- gameUpdateTick();
-
+ _vm->gameUpdateTick();
}
- // scene50_freeFont();
+ // freeFont();
- _gameSys->setAnimation(0, 0, 7);
- _gameSys->setAnimation(0, 0, 6);
- _gameSys->setAnimation(0, 0, 5);
- _gameSys->setAnimation(0, 0, 3);
+ _vm->_gameSys->setAnimation(0, 0, 7);
+ _vm->_gameSys->setAnimation(0, 0, 6);
+ _vm->_gameSys->setAnimation(0, 0, 5);
+ _vm->_gameSys->setAnimation(0, 0, 3);
- showCursor();
+ _vm->showCursor();
}
} // End of namespace Gnap
diff --git a/engines/gnap/scenes/scene50.h b/engines/gnap/scenes/scene50.h
new file mode 100644
index 0000000000..6cc4bc35cb
--- /dev/null
+++ b/engines/gnap/scenes/scene50.h
@@ -0,0 +1,87 @@
+/* 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_SCENE50_H
+#define GNAP_SCENE50_H
+
+#include "gnap/debugger.h"
+#include "gnap/scenes/scenecore.h"
+
+namespace Gnap {
+
+class GnapEngine;
+
+class Scene50: public Scene {
+public:
+ Scene50(GnapEngine *vm);
+ ~Scene50() {}
+
+ virtual int init();
+ virtual void updateHotspots();
+ virtual void run();
+ virtual void updateAnimations();
+ virtual void updateAnimationsCb() {};
+
+private:
+ bool _s50_fightDone;
+ int _s50_timesPlayed;
+ int _s50_timesPlayedModifier;
+ int _s50_attackCounter;
+ int _s50_roundNum;
+ int _s50_timeRemaining;
+ int _s50_leftTongueRoundsWon;
+ int _s50_rightTongueRoundsWon;
+ int _s50_leftTongueEnergyBarPos;
+ int _s50_rightTongueEnergyBarPos;
+ int _s50_leftTongueSequenceId;
+ int _s50_leftTongueId;
+ int _s50_leftTongueNextSequenceId;
+ int _s50_leftTongueNextId;
+ int _s50_leftTongueNextIdCtr;
+ int _s50_rightTongueSequenceId;
+ int _s50_rightTongueId;
+ int _s50_rightTongueNextSequenceId;
+ int _s50_rightTongueNextId;
+ int _s50_rightTongueNextIdCtr;
+ int _s50_leftTongueEnergy;
+ int _s50_rightTongueEnergy;
+
+ bool tongueWinsRound(int tongueNum);
+ void playWinAnim(int tongueNum, bool fightOver);
+ void delayTicks();
+ void initRound();
+ bool updateCountdown();
+ void drawCountdown(int value);
+ void playTonguesIdle();
+ void playRoundAnim(int roundNum);
+ bool updateEnergyBars(int newLeftBarPos, int newRightBarPos);
+ void waitForAnim(int animationIndex);
+ int checkInput();
+ int getRightTongueAction();
+ int getRightTongueActionTicks();
+ int getLeftTongueNextId();
+ int getRightTongueNextId();
+ void playWinBadgeAnim(int tongueNum);
+};
+
+} // End of namespace Gnap
+#endif // GNAP_SCENE50_H
diff --git a/engines/gnap/scenes/scenecore.cpp b/engines/gnap/scenes/scenecore.cpp
index a4d7604b0f..438604670b 100644
--- a/engines/gnap/scenes/scenecore.cpp
+++ b/engines/gnap/scenes/scenecore.cpp
@@ -71,6 +71,7 @@
#include "gnap/scenes/scene47.h"
#include "gnap/scenes/scene48.h"
#include "gnap/scenes/scene49.h"
+#include "gnap/scenes/scene50.h"
#include "gnap/scenes/scene54.h"
namespace Gnap {
@@ -412,7 +413,8 @@ int GnapEngine::initSceneLogic() {
initSceneGrid(21, 146, 11, 10);
break;
case 50:
- backgroundId = scene50_init();
+ _scene = new Scene50(this);
+ backgroundId = _scene->init();
_gameSys->setScaleValues(0, 500, 1, 1000);
initSceneGrid(21, 146, 11, 10);
break;
@@ -770,13 +772,14 @@ void GnapEngine::runSceneLogic() {
delete _scene;
break;
case 49:
- _scene = new Scene48(this);
- _scene->init();
+ _scene->run();
+ delete _scene;
if (_newSceneNum == 55)
_newSceneNum = 47;
break;
case 50:
- scene50_run();
+ _scene->run();
+ delete _scene;
_newSceneNum = _prevSceneNum;
break;
case 51: