aboutsummaryrefslogtreecommitdiff
path: root/engines/gnap/scenes
diff options
context:
space:
mode:
authorStrangerke2016-04-23 11:34:39 +0200
committerEugene Sandulenko2016-05-10 09:54:21 +0200
commitd1e7c9f594c6ad3ac31a3649e39db85e1be72d79 (patch)
treea26e69551168bb1baf37896ee477dafb180ace18 /engines/gnap/scenes
parent14ec2e9699caf9428a3f82b6542575595c6a4727 (diff)
downloadscummvm-rg350-d1e7c9f594c6ad3ac31a3649e39db85e1be72d79.tar.gz
scummvm-rg350-d1e7c9f594c6ad3ac31a3649e39db85e1be72d79.tar.bz2
scummvm-rg350-d1e7c9f594c6ad3ac31a3649e39db85e1be72d79.zip
GNAP: Refactor scenes 22 & 23
Diffstat (limited to 'engines/gnap/scenes')
-rw-r--r--engines/gnap/scenes/scene22.cpp238
-rw-r--r--engines/gnap/scenes/scene22.h52
-rw-r--r--engines/gnap/scenes/scene23.cpp252
-rw-r--r--engines/gnap/scenes/scene23.h50
-rw-r--r--engines/gnap/scenes/scenecore.cpp18
5 files changed, 357 insertions, 253 deletions
diff --git a/engines/gnap/scenes/scene22.cpp b/engines/gnap/scenes/scene22.cpp
index 364e42f03d..494af92b85 100644
--- a/engines/gnap/scenes/scene22.cpp
+++ b/engines/gnap/scenes/scene22.cpp
@@ -23,6 +23,7 @@
#include "gnap/gnap.h"
#include "gnap/gamesys.h"
#include "gnap/resource.h"
+#include "gnap/scenes/scene22.h"
namespace Gnap {
@@ -41,53 +42,57 @@ enum {
kASTalkCashier = 1
};
-int GnapEngine::scene22_init() {
- return 0x5E;
+Scene22::Scene22(GnapEngine *vm) : Scene(vm) {
+ _s22_caughtBefore = false;
+ _s22_cashierCtr = 3;
}
-void GnapEngine::scene22_updateHotspots() {
- setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
- setHotspot(kHSExitOutsideGrubCity, 0, 180, 184, 472, SF_EXIT_L_CURSOR, 3, 6);
- setHotspot(kHSExitBackGrubCity, 785, 405, 800, 585, SF_EXIT_R_CURSOR, 11, 9);
- setHotspot(kHSCashier, 578, 230, 660, 376, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 6, 8);
- setHotspot(kHSWalkArea1, 553, 0, 800, 542);
- setHotspot(kHSWalkArea2, 0, 0, 552, 488);
- setDeviceHotspot(kHSDevice, -1, -1, -1, -1);
- _hotspotsCount = 7;
+int Scene22::init() {
+ return 0x5E;
}
-void GnapEngine::scene22_run() {
+void Scene22::updateHotspots() {
+ _vm->setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
+ _vm->setHotspot(kHSExitOutsideGrubCity, 0, 180, 184, 472, SF_EXIT_L_CURSOR, 3, 6);
+ _vm->setHotspot(kHSExitBackGrubCity, 785, 405, 800, 585, SF_EXIT_R_CURSOR, 11, 9);
+ _vm->setHotspot(kHSCashier, 578, 230, 660, 376, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 6, 8);
+ _vm->setHotspot(kHSWalkArea1, 553, 0, 800, 542);
+ _vm->setHotspot(kHSWalkArea2, 0, 0, 552, 488);
+ _vm->setDeviceHotspot(kHSDevice, -1, -1, -1, -1);
+ _vm->_hotspotsCount = 7;
+}
- _gameSys->insertSequence(0x5D, 254, 0, 0, kSeqNone, 0, 0, 0);
+void Scene22::run() {
+ _vm->_gameSys->insertSequence(0x5D, 254, 0, 0, kSeqNone, 0, 0, 0);
_s22_currCashierSequenceId = 0x59;
_s22_nextCashierSequenceId = -1;
- _gameSys->setAnimation(0x59, 1, 3);
- _gameSys->insertSequence(_s22_currCashierSequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->_gameSys->setAnimation(0x59, 1, 3);
+ _vm->_gameSys->insertSequence(_s22_currCashierSequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
- _timers[6] = getRandom(30) + 20;
+ _vm->_timers[6] = _vm->getRandom(30) + 20;
- queueInsertDeviceIcon();
+ _vm->queueInsertDeviceIcon();
- if (_prevSceneNum == 20) {
- initGnapPos(2, 8, kDirBottomRight);
- initPlatypusPos(1, 8, kDirNone);
- endSceneInit();
+ if (_vm->_prevSceneNum == 20) {
+ _vm->initGnapPos(2, 8, kDirBottomRight);
+ _vm->initPlatypusPos(1, 8, kDirNone);
+ _vm->endSceneInit();
} else {
- initGnapPos(11, _hotspotsWalkPos[kHSExitBackGrubCity].y, kDirBottomRight);
- initPlatypusPos(11, _hotspotsWalkPos[kHSExitBackGrubCity].y + 1, kDirNone);
- endSceneInit();
- gnapWalkTo(8, 8, -1, 0x107B9, 1);
- platypusWalkTo(9, 8, -1, 0x107C2, 1);
+ _vm->initGnapPos(11, _vm->_hotspotsWalkPos[kHSExitBackGrubCity].y, kDirBottomRight);
+ _vm->initPlatypusPos(11, _vm->_hotspotsWalkPos[kHSExitBackGrubCity].y + 1, kDirNone);
+ _vm->endSceneInit();
+ _vm->gnapWalkTo(8, 8, -1, 0x107B9, 1);
+ _vm->platypusWalkTo(9, 8, -1, 0x107C2, 1);
}
- if (isFlag(kGFSceneFlag1)) {
+ if (_vm->isFlag(kGFSceneFlag1)) {
int storeDetectiveSeqId;
- setGrabCursorSprite(-1);
- invRemove(kItemCereals);
+ _vm->setGrabCursorSprite(-1);
+ _vm->invRemove(kItemCereals);
if (_s22_caughtBefore) {
- switch (getRandom(3)) {
+ switch (_vm->getRandom(3)) {
case 0:
storeDetectiveSeqId = 0x55;
break;
@@ -102,58 +107,56 @@ void GnapEngine::scene22_run() {
_s22_caughtBefore = true;
storeDetectiveSeqId = 0x54;
}
- _gameSys->waitForUpdate();
- _gameSys->requestClear1();
- _gameSys->drawSpriteToBackground(0, 0, 0x44);
- _gameSys->setAnimation(storeDetectiveSeqId, 256, 4);
- _gameSys->insertSequence(storeDetectiveSeqId, 256, 0, 0, kSeqNone, 0, 0, 0);
- while (_gameSys->getAnimationStatus(4) != 2) {
- gameUpdateTick();
+ _vm->_gameSys->waitForUpdate();
+ _vm->_gameSys->requestClear1();
+ _vm->_gameSys->drawSpriteToBackground(0, 0, 0x44);
+ _vm->_gameSys->setAnimation(storeDetectiveSeqId, 256, 4);
+ _vm->_gameSys->insertSequence(storeDetectiveSeqId, 256, 0, 0, kSeqNone, 0, 0, 0);
+ while (_vm->_gameSys->getAnimationStatus(4) != 2) {
+ _vm->gameUpdateTick();
}
- _sceneDone = true;
- _newSceneNum = 20;
+ _vm->_sceneDone = true;
+ _vm->_newSceneNum = 20;
_s22_caughtBefore = true;
}
- while (!_sceneDone) {
-
- updateMouseCursor();
- updateCursorByHotspot();
+ while (!_vm->_sceneDone) {
+ _vm->updateMouseCursor();
+ _vm->updateCursorByHotspot();
- testWalk(0, 0, -1, -1, -1, -1);
+ _vm->testWalk(0, 0, -1, -1, -1, -1);
- _sceneClickedHotspot = getClickedHotspotId();
- updateGrabCursorSprite(0, 0);
+ _vm->_sceneClickedHotspot = _vm->getClickedHotspotId();
+ _vm->updateGrabCursorSprite(0, 0);
- switch (_sceneClickedHotspot) {
-
+ switch (_vm->_sceneClickedHotspot) {
case kHSDevice:
- if (_gnapActionStatus < 0) {
- runMenu();
- scene22_updateHotspots();
+ if (_vm->_gnapActionStatus < 0) {
+ _vm->runMenu();
+ updateHotspots();
}
break;
case kHSPlatypus:
- if (_gnapActionStatus < 0) {
- if (_grabCursorSpriteIndex == kItemJoint) {
- gnapUseJointOnPlatypus();
- } else if (_grabCursorSpriteIndex >= 0) {
- playGnapImpossible(0, 0);
+ if (_vm->_gnapActionStatus < 0) {
+ if (_vm->_grabCursorSpriteIndex == kItemJoint) {
+ _vm->gnapUseJointOnPlatypus();
+ } else if (_vm->_grabCursorSpriteIndex >= 0) {
+ _vm->playGnapImpossible(0, 0);
} else {
- switch (_verbCursor) {
+ switch (_vm->_verbCursor) {
case LOOK_CURSOR:
- playGnapScratchingHead(_platX, _platY);
+ _vm->playGnapScratchingHead(_vm->_platX, _vm->_platY);
break;
case GRAB_CURSOR:
- gnapKissPlatypus(0);
+ _vm->gnapKissPlatypus(0);
break;
case TALK_CURSOR:
- playGnapBrainPulsating(_platX, _platY);
- playPlatypusSequence(getPlatypusSequenceId());
+ _vm->playGnapBrainPulsating(_vm->_platX, _vm->_platY);
+ _vm->playPlatypusSequence(_vm->getPlatypusSequenceId());
break;
case PLAT_CURSOR:
- playGnapImpossible(0, 0);
+ _vm->playGnapImpossible(0, 0);
break;
}
}
@@ -161,45 +164,45 @@ void GnapEngine::scene22_run() {
break;
case kHSExitOutsideGrubCity:
- if (_gnapActionStatus < 0) {
- _isLeavingScene = true;
- _newSceneNum = 20;
- gnapWalkTo(_hotspotsWalkPos[kHSExitOutsideGrubCity].x, _hotspotsWalkPos[kHSExitOutsideGrubCity].y, 0, 0x107AF, 1);
- _gnapActionStatus = kASLeaveScene;
- platypusWalkTo(_hotspotsWalkPos[kHSExitOutsideGrubCity].x, _hotspotsWalkPos[kHSExitOutsideGrubCity].y + 1, -1, 0x107C2, 1);
+ if (_vm->_gnapActionStatus < 0) {
+ _vm->_isLeavingScene = true;
+ _vm->_newSceneNum = 20;
+ _vm->gnapWalkTo(_vm->_hotspotsWalkPos[kHSExitOutsideGrubCity].x, _vm->_hotspotsWalkPos[kHSExitOutsideGrubCity].y, 0, 0x107AF, 1);
+ _vm->_gnapActionStatus = kASLeaveScene;
+ _vm->platypusWalkTo(_vm->_hotspotsWalkPos[kHSExitOutsideGrubCity].x, _vm->_hotspotsWalkPos[kHSExitOutsideGrubCity].y + 1, -1, 0x107C2, 1);
}
break;
case kHSExitBackGrubCity:
- if (_gnapActionStatus < 0) {
- _isLeavingScene = true;
- _newSceneNum = 23;
- gnapWalkTo(_hotspotsWalkPos[kHSExitBackGrubCity].x, _hotspotsWalkPos[kHSExitBackGrubCity].y, 0, 0x107AB, 1);
- _gnapActionStatus = kASLeaveScene;
- platypusWalkTo(_hotspotsWalkPos[kHSExitBackGrubCity].x, _hotspotsWalkPos[kHSExitBackGrubCity].y + 1, -1, 0x107C2, 1);
+ if (_vm->_gnapActionStatus < 0) {
+ _vm->_isLeavingScene = true;
+ _vm->_newSceneNum = 23;
+ _vm->gnapWalkTo(_vm->_hotspotsWalkPos[kHSExitBackGrubCity].x, _vm->_hotspotsWalkPos[kHSExitBackGrubCity].y, 0, 0x107AB, 1);
+ _vm->_gnapActionStatus = kASLeaveScene;
+ _vm->platypusWalkTo(_vm->_hotspotsWalkPos[kHSExitBackGrubCity].x, _vm->_hotspotsWalkPos[kHSExitBackGrubCity].y + 1, -1, 0x107C2, 1);
}
break;
case kHSCashier:
- if (_gnapActionStatus < 0) {
- if (_grabCursorSpriteIndex >= 0) {
- playGnapShowCurrItem(_hotspotsWalkPos[kHSCashier].x, _hotspotsWalkPos[kHSCashier].y, 8, 4);
+ if (_vm->_gnapActionStatus < 0) {
+ if (_vm->_grabCursorSpriteIndex >= 0) {
+ _vm->playGnapShowCurrItem(_vm->_hotspotsWalkPos[kHSCashier].x, _vm->_hotspotsWalkPos[kHSCashier].y, 8, 4);
} else {
- switch (_verbCursor) {
+ switch (_vm->_verbCursor) {
case LOOK_CURSOR:
- playGnapScratchingHead(8, 4);
+ _vm->playGnapScratchingHead(8, 4);
break;
case GRAB_CURSOR:
- playGnapImpossible(0, 0);
+ _vm->playGnapImpossible(0, 0);
break;
case TALK_CURSOR:
- _gnapIdleFacing = kDirUpRight;
- gnapWalkTo(_hotspotsWalkPos[kHSCashier].x, _hotspotsWalkPos[kHSCashier].y,
- 0, getGnapSequenceId(gskBrainPulsating, 0, 0) | 0x10000, 1);
- _gnapActionStatus = kASTalkCashier;
+ _vm->_gnapIdleFacing = kDirUpRight;
+ _vm->gnapWalkTo(_vm->_hotspotsWalkPos[kHSCashier].x, _vm->_hotspotsWalkPos[kHSCashier].y,
+ 0, _vm->getGnapSequenceId(gskBrainPulsating, 0, 0) | 0x10000, 1);
+ _vm->_gnapActionStatus = kASTalkCashier;
break;
case PLAT_CURSOR:
- gnapUseDeviceOnPlatypuss();
+ _vm->gnapUseDeviceOnPlatypuss();
break;
}
}
@@ -208,26 +211,25 @@ void GnapEngine::scene22_run() {
case kHSWalkArea1:
case kHSWalkArea2:
- gnapWalkTo(-1, -1, -1, -1, 1);
+ _vm->gnapWalkTo(-1, -1, -1, -1, 1);
break;
default:
- if (_mouseClickState._left) {
- gnapWalkTo(-1, -1, -1, -1, 1);
- _mouseClickState._left = false;
+ if (_vm->_mouseClickState._left) {
+ _vm->gnapWalkTo(-1, -1, -1, -1, 1);
+ _vm->_mouseClickState._left = false;
}
break;
-
}
- scene22_updateAnimations();
+ updateAnimations();
- if (!_isLeavingScene) {
- updatePlatypusIdleSequence();
- updateGnapIdleSequence();
- if (!_timers[6] && _s22_nextCashierSequenceId == -1) {
- _timers[6] = getRandom(30) + 20;
- if (getRandom(8) != 0) {
+ if (!_vm->_isLeavingScene) {
+ _vm->updatePlatypusIdleSequence();
+ _vm->updateGnapIdleSequence();
+ if (!_vm->_timers[6] && _s22_nextCashierSequenceId == -1) {
+ _vm->_timers[6] = _vm->getRandom(30) + 20;
+ if (_vm->getRandom(8) != 0) {
_s22_nextCashierSequenceId = 0x59;
} else {
_s22_cashierCtr = (_s22_cashierCtr + 1) % 3;
@@ -249,46 +251,42 @@ void GnapEngine::scene22_run() {
}
}
- checkGameKeys();
+ _vm->checkGameKeys();
- if (isKeyStatus1(8)) {
- clearKeyStatus1(8);
- runMenu();
- scene22_updateHotspots();
- _timers[2] = getRandom(30) + 20;
- _timers[3] = 400;
- _timers[1] = getRandom(20) + 30;
- _timers[0] = getRandom(75) + 75;
+ if (_vm->isKeyStatus1(8)) {
+ _vm->clearKeyStatus1(8);
+ _vm->runMenu();
+ updateHotspots();
+ _vm->_timers[2] = _vm->getRandom(30) + 20;
+ _vm->_timers[3] = 400;
+ _vm->_timers[1] = _vm->getRandom(20) + 30;
+ _vm->_timers[0] = _vm->getRandom(75) + 75;
}
- gameUpdateTick();
-
+ _vm->gameUpdateTick();
}
-
}
-void GnapEngine::scene22_updateAnimations() {
-
- if (_gameSys->getAnimationStatus(0) == 2) {
- _gameSys->setAnimation(0, 0, 0);
- switch (_gnapActionStatus) {
+void Scene22::updateAnimations() {
+ if (_vm->_gameSys->getAnimationStatus(0) == 2) {
+ _vm->_gameSys->setAnimation(0, 0, 0);
+ switch (_vm->_gnapActionStatus) {
case kASLeaveScene:
- _sceneDone = true;
+ _vm->_sceneDone = true;
break;
case kASTalkCashier:
_s22_nextCashierSequenceId = 0x5C;
break;
}
- _gnapActionStatus = -1;
+ _vm->_gnapActionStatus = -1;
}
- if (_gameSys->getAnimationStatus(3) == 2 && _s22_nextCashierSequenceId != -1) {
- _gameSys->setAnimation(_s22_nextCashierSequenceId, 1, 3);
- _gameSys->insertSequence(_s22_nextCashierSequenceId, 1, _s22_currCashierSequenceId, 1, kSeqSyncWait, 0, 0, 0);
+ if (_vm->_gameSys->getAnimationStatus(3) == 2 && _s22_nextCashierSequenceId != -1) {
+ _vm->_gameSys->setAnimation(_s22_nextCashierSequenceId, 1, 3);
+ _vm->_gameSys->insertSequence(_s22_nextCashierSequenceId, 1, _s22_currCashierSequenceId, 1, kSeqSyncWait, 0, 0, 0);
_s22_currCashierSequenceId = _s22_nextCashierSequenceId;
_s22_nextCashierSequenceId = -1;
}
-
}
} // End of namespace Gnap
diff --git a/engines/gnap/scenes/scene22.h b/engines/gnap/scenes/scene22.h
new file mode 100644
index 0000000000..44afa10da7
--- /dev/null
+++ b/engines/gnap/scenes/scene22.h
@@ -0,0 +1,52 @@
+/* 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_SCENE22_H
+#define GNAP_SCENE22_H
+
+#include "gnap/debugger.h"
+#include "gnap/scenes/scenecore.h"
+
+namespace Gnap {
+
+class GnapEngine;
+
+class Scene22: public Scene {
+public:
+ Scene22(GnapEngine *vm);
+ ~Scene22() {}
+
+ virtual int init();
+ virtual void updateHotspots();
+ virtual void run();
+ virtual void updateAnimations();
+ virtual void updateAnimationsCb() {};
+
+private:
+ int _s22_currCashierSequenceId;
+ int _s22_nextCashierSequenceId;
+ bool _s22_caughtBefore;
+ int _s22_cashierCtr;
+};
+
+} // End of namespace Gnap
+#endif // GNAP_SCENE22_H
diff --git a/engines/gnap/scenes/scene23.cpp b/engines/gnap/scenes/scene23.cpp
index a6b4c1fd80..75838f4482 100644
--- a/engines/gnap/scenes/scene23.cpp
+++ b/engines/gnap/scenes/scene23.cpp
@@ -23,6 +23,7 @@
#include "gnap/gnap.h"
#include "gnap/gamesys.h"
#include "gnap/resource.h"
+#include "gnap/scenes/scene23.h"
namespace Gnap {
@@ -42,90 +43,92 @@ enum {
kASLeaveScene = 3
};
-int GnapEngine::scene23_init() {
+Scene23::Scene23(GnapEngine *vm) : Scene(vm) {
+ _s23_currStoreClerkSequenceId = -1;
+ _s23_nextStoreClerkSequenceId = -1;
+}
+
+int Scene23::init() {
return 0xC0;
}
-void GnapEngine::scene23_updateHotspots() {
- setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
- setHotspot(kHSExitFrontGrubCity, 0, 250, 15, 550, SF_EXIT_L_CURSOR | SF_WALKABLE, 0, 7);
- setHotspot(kHSCereals, 366, 332, 414, 408, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 4, 7);
- setHotspot(kHSWalkArea1, 0, 0, 340, 460);
- setHotspot(kHSWalkArea2, 340, 0, 800, 501);
- setDeviceHotspot(kHSDevice, -1, -1, -1, -1);
- _hotspotsCount = 6;
+void Scene23::updateHotspots() {
+ _vm->setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
+ _vm->setHotspot(kHSExitFrontGrubCity, 0, 250, 15, 550, SF_EXIT_L_CURSOR | SF_WALKABLE, 0, 7);
+ _vm->setHotspot(kHSCereals, 366, 332, 414, 408, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 4, 7);
+ _vm->setHotspot(kHSWalkArea1, 0, 0, 340, 460);
+ _vm->setHotspot(kHSWalkArea2, 340, 0, 800, 501);
+ _vm->setDeviceHotspot(kHSDevice, -1, -1, -1, -1);
+ _vm->_hotspotsCount = 6;
}
-void GnapEngine::scene23_run() {
-
- _timers[4] = getRandom(100) + 200;
- _timers[5] = getRandom(100) + 200;
+void Scene23::run() {
+ _vm->_timers[4] = _vm->getRandom(100) + 200;
+ _vm->_timers[5] = _vm->getRandom(100) + 200;
_s23_currStoreClerkSequenceId = 0xB4;
_s23_nextStoreClerkSequenceId = -1;
- _gameSys->setAnimation(0xB4, 1, 4);
- _gameSys->insertSequence(_s23_currStoreClerkSequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->_gameSys->setAnimation(0xB4, 1, 4);
+ _vm->_gameSys->insertSequence(_s23_currStoreClerkSequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
- queueInsertDeviceIcon();
+ _vm->queueInsertDeviceIcon();
- initGnapPos(-1, 7, kDirBottomRight);
- initPlatypusPos(-2, 7, kDirNone);
- _gameSys->insertSequence(0xBD, 255, 0, 0, kSeqNone, 0, 0, 0);
- _gameSys->insertSequence(0xBF, 2, 0, 0, kSeqNone, 0, 0, 0);
- endSceneInit();
+ _vm->initGnapPos(-1, 7, kDirBottomRight);
+ _vm->initPlatypusPos(-2, 7, kDirNone);
+ _vm->_gameSys->insertSequence(0xBD, 255, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xBF, 2, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->endSceneInit();
- platypusWalkTo(1, 7, -1, 0x107C2, 1);
+ _vm->platypusWalkTo(1, 7, -1, 0x107C2, 1);
- if (isFlag(kGFUnk24)) {
- gnapWalkTo(2, 7, -1, 0x107B9, 1);
+ if (_vm->isFlag(kGFUnk24)) {
+ _vm->gnapWalkTo(2, 7, -1, 0x107B9, 1);
} else {
- gnapWalkTo(2, 7, 0, 0x107B9, 1);
- while (_gameSys->getAnimationStatus(0) != 2)
- gameUpdateTick();
- playSequences(0x48, 0xBA, 0xBB, 0xBC);
- setFlag(kGFUnk24);
+ _vm->gnapWalkTo(2, 7, 0, 0x107B9, 1);
+ while (_vm->_gameSys->getAnimationStatus(0) != 2)
+ _vm->gameUpdateTick();
+ _vm->playSequences(0x48, 0xBA, 0xBB, 0xBC);
+ _vm->setFlag(kGFUnk24);
}
- while (!_sceneDone) {
-
- updateMouseCursor();
- updateCursorByHotspot();
+ while (!_vm->_sceneDone) {
+ _vm->updateMouseCursor();
+ _vm->updateCursorByHotspot();
- testWalk(0, 3, -1, -1, -1, -1);
+ _vm->testWalk(0, 3, -1, -1, -1, -1);
- _sceneClickedHotspot = getClickedHotspotId();
- updateGrabCursorSprite(0, 0);
+ _vm->_sceneClickedHotspot = _vm->getClickedHotspotId();
+ _vm->updateGrabCursorSprite(0, 0);
- switch (_sceneClickedHotspot) {
-
+ switch (_vm->_sceneClickedHotspot) {
case kHSDevice:
- if (_gnapActionStatus < 0) {
- runMenu();
- scene23_updateHotspots();
+ if (_vm->_gnapActionStatus < 0) {
+ _vm->runMenu();
+ updateHotspots();
}
break;
case kHSPlatypus:
- if (_gnapActionStatus < 0) {
- if (_grabCursorSpriteIndex == kItemJoint) {
- gnapUseJointOnPlatypus();
- } else if (_grabCursorSpriteIndex >= 0) {
- playGnapImpossible(0, 0);
+ if (_vm->_gnapActionStatus < 0) {
+ if (_vm->_grabCursorSpriteIndex == kItemJoint) {
+ _vm->gnapUseJointOnPlatypus();
+ } else if (_vm->_grabCursorSpriteIndex >= 0) {
+ _vm->playGnapImpossible(0, 0);
} else {
- switch (_verbCursor) {
+ switch (_vm->_verbCursor) {
case LOOK_CURSOR:
- playGnapScratchingHead(_platX, _platY);
+ _vm->playGnapScratchingHead(_vm->_platX, _vm->_platY);
break;
case GRAB_CURSOR:
- gnapKissPlatypus(0);
+ _vm->gnapKissPlatypus(0);
break;
case TALK_CURSOR:
- playGnapBrainPulsating(_platX, _platY);
- playPlatypusSequence(getPlatypusSequenceId());
+ _vm->playGnapBrainPulsating(_vm->_platX, _vm->_platY);
+ _vm->playPlatypusSequence(_vm->getPlatypusSequenceId());
break;
case PLAT_CURSOR:
- playGnapImpossible(0, 0);
+ _vm->playGnapImpossible(0, 0);
break;
}
}
@@ -133,35 +136,35 @@ void GnapEngine::scene23_run() {
break;
case kHSCereals:
- if (_gnapActionStatus < 0) {
- if (_grabCursorSpriteIndex >= 0) {
- playGnapShowCurrItem(_hotspotsWalkPos[kHSCereals].x, _hotspotsWalkPos[kHSCereals].y, 5, 4);
+ if (_vm->_gnapActionStatus < 0) {
+ if (_vm->_grabCursorSpriteIndex >= 0) {
+ _vm->playGnapShowCurrItem(_vm->_hotspotsWalkPos[kHSCereals].x, _vm->_hotspotsWalkPos[kHSCereals].y, 5, 4);
} else {
- switch (_verbCursor) {
+ switch (_vm->_verbCursor) {
case LOOK_CURSOR:
- if (isFlag(kGFSceneFlag1))
- playGnapMoan2(0, 0);
+ if (_vm->isFlag(kGFSceneFlag1))
+ _vm->playGnapMoan2(0, 0);
else {
- gnapWalkTo(_hotspotsWalkPos[kHSCereals].x, _hotspotsWalkPos[kHSCereals].y,
- 0, getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
- _gnapActionStatus = kASLookCereals;
+ _vm->gnapWalkTo(_vm->_hotspotsWalkPos[kHSCereals].x, _vm->_hotspotsWalkPos[kHSCereals].y,
+ 0, _vm->getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
+ _vm->_gnapActionStatus = kASLookCereals;
}
break;
case GRAB_CURSOR:
- if (isFlag(kGFSceneFlag1))
- playGnapImpossible(0, 0);
+ if (_vm->isFlag(kGFSceneFlag1))
+ _vm->playGnapImpossible(0, 0);
else {
- _gnapIdleFacing = kDirBottomRight;
- gnapWalkTo(_hotspotsWalkPos[kHSCereals].x, _hotspotsWalkPos[kHSCereals].y,
- 0, getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
- setFlag(kGFSceneFlag1);
- _gnapActionStatus = kASGrabCereals;
- invAdd(kItemCereals);
+ _vm->_gnapIdleFacing = kDirBottomRight;
+ _vm->gnapWalkTo(_vm->_hotspotsWalkPos[kHSCereals].x, _vm->_hotspotsWalkPos[kHSCereals].y,
+ 0, _vm->getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
+ _vm->setFlag(kGFSceneFlag1);
+ _vm->_gnapActionStatus = kASGrabCereals;
+ _vm->invAdd(kItemCereals);
}
break;
case TALK_CURSOR:
case PLAT_CURSOR:
- playGnapImpossible(0, 0);
+ _vm->playGnapImpossible(0, 0);
break;
}
}
@@ -169,109 +172,105 @@ void GnapEngine::scene23_run() {
break;
case kHSExitFrontGrubCity:
- if (_gnapActionStatus < 0) {
- _isLeavingScene = true;
- _newSceneNum = 22;
- gnapWalkTo(_hotspotsWalkPos[kHSExitFrontGrubCity].x, _hotspotsWalkPos[kHSExitFrontGrubCity].y, 0, 0x107AF, 1);
- _gnapActionStatus = kASLeaveScene;
- platypusWalkTo(_hotspotsWalkPos[kHSExitFrontGrubCity].x, _hotspotsWalkPos[kHSExitFrontGrubCity].y - 1, -1, 0x107C2, 1);
+ if (_vm->_gnapActionStatus < 0) {
+ _vm->_isLeavingScene = true;
+ _vm->_newSceneNum = 22;
+ _vm->gnapWalkTo(_vm->_hotspotsWalkPos[kHSExitFrontGrubCity].x, _vm->_hotspotsWalkPos[kHSExitFrontGrubCity].y, 0, 0x107AF, 1);
+ _vm->_gnapActionStatus = kASLeaveScene;
+ _vm->platypusWalkTo(_vm->_hotspotsWalkPos[kHSExitFrontGrubCity].x, _vm->_hotspotsWalkPos[kHSExitFrontGrubCity].y - 1, -1, 0x107C2, 1);
}
break;
case kHSWalkArea1:
case kHSWalkArea2:
- if (_gnapActionStatus < 0)
- gnapWalkTo(-1, -1, -1, -1, 1);
+ if (_vm->_gnapActionStatus < 0)
+ _vm->gnapWalkTo(-1, -1, -1, -1, 1);
break;
default:
- if (_mouseClickState._left) {
- gnapWalkTo(-1, -1, -1, -1, 1);
- _mouseClickState._left = false;
+ if (_vm->_mouseClickState._left) {
+ _vm->gnapWalkTo(-1, -1, -1, -1, 1);
+ _vm->_mouseClickState._left = false;
}
break;
-
}
- scene23_updateAnimations();
+ updateAnimations();
- if (!_isLeavingScene) {
- updatePlatypusIdleSequence();
- updateGnapIdleSequence();
- if (!_timers[4] && _gnapActionStatus == -1) {
- _timers[4] = getRandom(100) + 200;
- switch (getRandom(4)) {
+ if (!_vm->_isLeavingScene) {
+ _vm->updatePlatypusIdleSequence();
+ _vm->updateGnapIdleSequence();
+ if (!_vm->_timers[4] && _vm->_gnapActionStatus == -1) {
+ _vm->_timers[4] = _vm->getRandom(100) + 200;
+ switch (_vm->getRandom(4)) {
case 0:
- _gameSys->insertSequence(0xB7, 256, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xB7, 256, 0, 0, kSeqNone, 0, 0, 0);
break;
case 1:
- _gameSys->insertSequence(0xB8, 256, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xB8, 256, 0, 0, kSeqNone, 0, 0, 0);
break;
case 2:
case 3:
- _gameSys->insertSequence(0xB9, 256, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0xB9, 256, 0, 0, kSeqNone, 0, 0, 0);
break;
}
}
- if (!_timers[5]) {
- _timers[5] = getRandom(100) + 200;
- switch (getRandom(3)) {
+ if (!_vm->_timers[5]) {
+ _vm->_timers[5] = _vm->getRandom(100) + 200;
+ switch (_vm->getRandom(3)) {
case 0:
- playSound(0xCE, false);
+ _vm->playSound(0xCE, false);
break;
case 1:
- playSound(0xD0, false);
+ _vm->playSound(0xD0, false);
break;
case 2:
- playSound(0xCF, false);
+ _vm->playSound(0xCF, false);
break;
}
}
}
- checkGameKeys();
+ _vm->checkGameKeys();
- if (isKeyStatus1(8)) {
- clearKeyStatus1(8);
- runMenu();
- scene23_updateHotspots();
+ if (_vm->isKeyStatus1(8)) {
+ _vm->clearKeyStatus1(8);
+ _vm->runMenu();
+ updateHotspots();
}
- gameUpdateTick();
-
+ _vm->gameUpdateTick();
}
-
}
-void GnapEngine::scene23_updateAnimations() {
-
- if (_gameSys->getAnimationStatus(0) == 2) {
- _gameSys->setAnimation(0, 0, 0);
- switch (_gnapActionStatus) {
+void Scene23::updateAnimations() {
+ if (_vm->_gameSys->getAnimationStatus(0) == 2) {
+ _vm->_gameSys->setAnimation(0, 0, 0);
+ switch (_vm->_gnapActionStatus) {
case kASLookCereals:
- showFullScreenSprite(0x48);
- _gnapActionStatus = -1;
+ _vm->showFullScreenSprite(0x48);
+ _vm->_gnapActionStatus = -1;
break;
case kASGrabCereals:
- _gameSys->setAnimation(0xBE, _gnapId, 0);
- _gameSys->insertSequence(0xBE, _gnapId, makeRid(_gnapSequenceDatNum, _gnapSequenceId), _gnapId, kSeqSyncWait, 0, 0, 0);
- _gameSys->requestRemoveSequence(0xBF, 2);
- _gnapSequenceDatNum = 0;
- _gnapSequenceId = 0xBE;
- _gnapActionStatus = kASGrabCerealsDone;
+ _vm->_gameSys->setAnimation(0xBE, _vm->_gnapId, 0);
+ _vm->_gameSys->insertSequence(0xBE, _vm->_gnapId, makeRid(_vm->_gnapSequenceDatNum, _vm->_gnapSequenceId), _vm->_gnapId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->requestRemoveSequence(0xBF, 2);
+ _vm->_gnapSequenceDatNum = 0;
+ _vm->_gnapSequenceId = 0xBE;
+ _vm->_gnapActionStatus = kASGrabCerealsDone;
break;
case kASGrabCerealsDone:
- setGrabCursorSprite(kItemCereals);
- _gnapActionStatus = -1;
+ _vm->setGrabCursorSprite(kItemCereals);
+ _vm->_gnapActionStatus = -1;
break;
case kASLeaveScene:
- _sceneDone = true;
+ _vm->_sceneDone = true;
break;
}
}
- if (_gameSys->getAnimationStatus(4) == 2 && _s23_nextStoreClerkSequenceId == -1) {
- switch (getRandom(8)) {
+ if (_vm->_gameSys->getAnimationStatus(4) == 2 && _s23_nextStoreClerkSequenceId == -1) {
+ switch (_vm->getRandom(8)) {
case 0:
case 1:
case 2:
@@ -286,12 +285,11 @@ void GnapEngine::scene23_updateAnimations() {
_s23_nextStoreClerkSequenceId = 0xB6;
break;
}
- _gameSys->setAnimation(_s23_nextStoreClerkSequenceId, 1, 4);
- _gameSys->insertSequence(_s23_nextStoreClerkSequenceId, 1, _s23_currStoreClerkSequenceId, 1, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->setAnimation(_s23_nextStoreClerkSequenceId, 1, 4);
+ _vm->_gameSys->insertSequence(_s23_nextStoreClerkSequenceId, 1, _s23_currStoreClerkSequenceId, 1, kSeqSyncWait, 0, 0, 0);
_s23_currStoreClerkSequenceId = _s23_nextStoreClerkSequenceId;
_s23_nextStoreClerkSequenceId = -1;
}
-
}
} // End of namespace Gnap
diff --git a/engines/gnap/scenes/scene23.h b/engines/gnap/scenes/scene23.h
new file mode 100644
index 0000000000..73543c9997
--- /dev/null
+++ b/engines/gnap/scenes/scene23.h
@@ -0,0 +1,50 @@
+/* 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_SCENE23_H
+#define GNAP_SCENE23_H
+
+#include "gnap/debugger.h"
+#include "gnap/scenes/scenecore.h"
+
+namespace Gnap {
+
+class GnapEngine;
+
+class Scene23: public Scene {
+public:
+ Scene23(GnapEngine *vm);
+ ~Scene23() {}
+
+ virtual int init();
+ virtual void updateHotspots();
+ virtual void run();
+ virtual void updateAnimations();
+ virtual void updateAnimationsCb() {};
+
+private:
+ int _s23_currStoreClerkSequenceId;
+ int _s23_nextStoreClerkSequenceId;
+};
+
+} // End of namespace Gnap
+#endif // GNAP_SCENE23_H
diff --git a/engines/gnap/scenes/scenecore.cpp b/engines/gnap/scenes/scenecore.cpp
index 42813a21f9..0ecb9e530c 100644
--- a/engines/gnap/scenes/scenecore.cpp
+++ b/engines/gnap/scenes/scenecore.cpp
@@ -47,6 +47,8 @@
#include "gnap/scenes/scene19.h"
#include "gnap/scenes/scene20.h"
#include "gnap/scenes/scene21.h"
+#include "gnap/scenes/scene22.h"
+#include "gnap/scenes/scene23.h"
#include "gnap/scenes/scene47.h"
#include "gnap/scenes/scene48.h"
#include "gnap/scenes/scene54.h"
@@ -208,14 +210,16 @@ int GnapEngine::initSceneLogic() {
initSceneGrid(21, 146, 11, 10);
break;
case 22:
- backgroundId = scene22_init();
- scene22_updateHotspots();
+ _scene = new Scene22(this);
+ backgroundId = _scene->init();
+ _scene->updateHotspots();
_gameSys->setScaleValues(0, 500, 1, 1000);
initSceneGrid(21, 146, 11, 10);
break;
case 23:
- backgroundId = scene23_init();
- scene23_updateHotspots();
+ _scene = new Scene23(this);
+ backgroundId = _scene->init();
+ _scene->updateHotspots();
_gameSys->setScaleValues(0, 500, 1, 1000);
initSceneGrid(21, 146, 11, 10);
break;
@@ -530,12 +534,14 @@ void GnapEngine::runSceneLogic() {
_newSceneNum = 20;
break;
case 22:
- scene22_run();
+ _scene->run();
+ delete _scene;
if (_newSceneNum == 55)
_newSceneNum = 20;
break;
case 23:
- scene23_run();
+ _scene->run();
+ delete _scene;
if (_newSceneNum == 55)
_newSceneNum = 20;
break;