aboutsummaryrefslogtreecommitdiff
path: root/engines/gnap/scenes
diff options
context:
space:
mode:
authorStrangerke2016-04-20 07:21:55 +0200
committerEugene Sandulenko2016-05-10 09:54:21 +0200
commitca21ed461514939da5a126482c164c089c23051e (patch)
tree102562bc82ae6606ef39f45a6a5b80230e90d2aa /engines/gnap/scenes
parent58827530140a94c17053d02774884b23fd1dcab2 (diff)
downloadscummvm-rg350-ca21ed461514939da5a126482c164c089c23051e.tar.gz
scummvm-rg350-ca21ed461514939da5a126482c164c089c23051e.tar.bz2
scummvm-rg350-ca21ed461514939da5a126482c164c089c23051e.zip
GNAP: Refactor scene 5
Diffstat (limited to 'engines/gnap/scenes')
-rw-r--r--engines/gnap/scenes/scene05.cpp485
-rw-r--r--engines/gnap/scenes/scene05.h50
-rw-r--r--engines/gnap/scenes/scenecore.cpp17
3 files changed, 303 insertions, 249 deletions
diff --git a/engines/gnap/scenes/scene05.cpp b/engines/gnap/scenes/scene05.cpp
index 405bd2aba3..f28a37daa1 100644
--- a/engines/gnap/scenes/scene05.cpp
+++ b/engines/gnap/scenes/scene05.cpp
@@ -23,6 +23,7 @@
#include "gnap/gnap.h"
#include "gnap/gamesys.h"
#include "gnap/resource.h"
+#include "gnap/scenes/scene05.h"
namespace Gnap {
@@ -51,107 +52,109 @@ enum {
kASLeaveScene = 12
};
-int GnapEngine::scene05_init() {
- _gameSys->setAnimation(0, 0, 0);
- _gameSys->setAnimation(0, 0, 1);
- _gameSys->setAnimation(0, 0, 3);
- return isFlag(kGFBarnPadlockOpen) ? 0x151 : 0x150;
+Scene05::Scene05(GnapEngine *vm) : Scene(vm) {
+ _s05_nextChickenSequenceId = -1;
+ _s05_currChickenSequenceId = -1;
}
-void GnapEngine::scene05_updateHotspots() {
- setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_DISABLED | SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
- setHotspot(kHSHaystack, 236, 366, 372, 442, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 5, 7);
- setHotspot(kHSPadlock, 386, 230, 626, 481, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 5, 7);
- setHotspot(kHSLadder, 108, 222, 207, 444, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 4, 7);
- setHotspot(kHSExitHouse, 0, 395, 20, 600, SF_EXIT_L_CURSOR | SF_WALKABLE, 0, 8);
- setHotspot(kHSChicken, 612, 462, 722, 564, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 7, 8);
- setHotspot(kHSWalkArea1, 104, 0, 421, 480);
- setHotspot(kHSWalkArea2, 422, 0, 800, 487);
- setHotspot(kHSWalkArea3, 0, 0, 104, 499);
- setDeviceHotspot(kHSDevice, -1, -1, -1, -1);
- if (isFlag(kGFPlatypus))
- _hotspots[kHSPlatypus]._flags = SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR;
- if (isFlag(kGFBarnPadlockOpen))
- _hotspots[kHSPadlock]._flags = SF_EXIT_U_CURSOR;
- _hotspotsCount = 10;
+int Scene05::init() {
+ _vm->_gameSys->setAnimation(0, 0, 0);
+ _vm->_gameSys->setAnimation(0, 0, 1);
+ _vm->_gameSys->setAnimation(0, 0, 3);
+ return _vm->isFlag(kGFBarnPadlockOpen) ? 0x151 : 0x150;
}
-void GnapEngine::scene05_run() {
+void Scene05::updateHotspots() {
+ _vm->setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_DISABLED | SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
+ _vm->setHotspot(kHSHaystack, 236, 366, 372, 442, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 5, 7);
+ _vm->setHotspot(kHSPadlock, 386, 230, 626, 481, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 5, 7);
+ _vm->setHotspot(kHSLadder, 108, 222, 207, 444, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 4, 7);
+ _vm->setHotspot(kHSExitHouse, 0, 395, 20, 600, SF_EXIT_L_CURSOR | SF_WALKABLE, 0, 8);
+ _vm->setHotspot(kHSChicken, 612, 462, 722, 564, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 7, 8);
+ _vm->setHotspot(kHSWalkArea1, 104, 0, 421, 480);
+ _vm->setHotspot(kHSWalkArea2, 422, 0, 800, 487);
+ _vm->setHotspot(kHSWalkArea3, 0, 0, 104, 499);
+ _vm->setDeviceHotspot(kHSDevice, -1, -1, -1, -1);
+ if (_vm->isFlag(kGFPlatypus))
+ _vm->_hotspots[kHSPlatypus]._flags = SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR;
+ if (_vm->isFlag(kGFBarnPadlockOpen))
+ _vm->_hotspots[kHSPadlock]._flags = SF_EXIT_U_CURSOR;
+ _vm->_hotspotsCount = 10;
+}
- playSound(0x1091C, true);
- startSoundTimerC(7);
+void Scene05::run() {
+ _vm->playSound(0x1091C, true);
+ _vm->startSoundTimerC(7);
_s05_currChickenSequenceId = 0x142;
- _gameSys->setAnimation(0x142, 100, 3);
- _gameSys->insertSequence(0x142, 100, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->_gameSys->setAnimation(0x142, 100, 3);
+ _vm->_gameSys->insertSequence(0x142, 100, 0, 0, kSeqNone, 0, 0, 0);
_s05_nextChickenSequenceId = -1;
- _timers[5] = getRandom(10) + 30;
- _timers[6] = getRandom(150) + 300;
+ _vm->_timers[5] = _vm->getRandom(10) + 30;
+ _vm->_timers[6] = _vm->getRandom(150) + 300;
- if (isFlag(kGFBarnPadlockOpen))
- _gameSys->insertSequence(0x14A, 141, 0, 0, kSeqNone, 0, 0, 0);
+ if (_vm->isFlag(kGFBarnPadlockOpen))
+ _vm->_gameSys->insertSequence(0x14A, 141, 0, 0, kSeqNone, 0, 0, 0);
- queueInsertDeviceIcon();
+ _vm->queueInsertDeviceIcon();
- if (_prevSceneNum != 6 && _prevSceneNum != 36) {
- initGnapPos(-1, 8, kDirBottomRight);
- if (isFlag(kGFPlatypus))
- initPlatypusPos(-1, 9, kDirNone);
- endSceneInit();
- if (isFlag(kGFPlatypus))
- platypusWalkTo(2, 8, -1, 0x107C2, 1);
- gnapWalkTo(2, 9, -1, 0x107B9, 1);
+ if (_vm->_prevSceneNum != 6 && _vm->_prevSceneNum != 36) {
+ _vm->initGnapPos(-1, 8, kDirBottomRight);
+ if (_vm->isFlag(kGFPlatypus))
+ _vm->initPlatypusPos(-1, 9, kDirNone);
+ _vm->endSceneInit();
+ if (_vm->isFlag(kGFPlatypus))
+ _vm->platypusWalkTo(2, 8, -1, 0x107C2, 1);
+ _vm->gnapWalkTo(2, 9, -1, 0x107B9, 1);
} else {
- initGnapPos(6, 8, kDirBottomRight);
- if (isFlag(kGFPlatypus))
- initPlatypusPos(7, 9, kDirNone);
- endSceneInit();
+ _vm->initGnapPos(6, 8, kDirBottomRight);
+ if (_vm->isFlag(kGFPlatypus))
+ _vm->initPlatypusPos(7, 9, kDirNone);
+ _vm->endSceneInit();
}
- while (!_sceneDone) {
+ while (!_vm->_sceneDone) {
+ _vm->updateMouseCursor();
+ _vm->updateCursorByHotspot();
- updateMouseCursor();
- updateCursorByHotspot();
+ _vm->testWalk(0, 12, -1, -1, -1, -1);
- testWalk(0, 12, -1, -1, -1, -1);
+ _vm->_sceneClickedHotspot = _vm->getClickedHotspotId();
+ _vm->updateGrabCursorSprite(0, 0);
- _sceneClickedHotspot = getClickedHotspotId();
- updateGrabCursorSprite(0, 0);
-
- switch (_sceneClickedHotspot) {
-
+ switch (_vm->_sceneClickedHotspot) {
case kHSDevice:
- if (_gnapActionStatus < 0) {
- runMenu();
- scene05_updateHotspots();
+ if (_vm->_gnapActionStatus < 0) {
+ _vm->runMenu();
+ updateHotspots();
}
break;
case kHSPlatypus:
- if (_gnapActionStatus < 0 && isFlag(kGFPlatypus)) {
- if (_grabCursorSpriteIndex == kItemDisguise) {
- gnapUseDisguiseOnPlatypus();
- } else if (_grabCursorSpriteIndex >= 0) {
- playGnapImpossible(0, 0);
+ if (_vm->_gnapActionStatus < 0 && _vm->isFlag(kGFPlatypus)) {
+ if (_vm->_grabCursorSpriteIndex == kItemDisguise) {
+ _vm->gnapUseDisguiseOnPlatypus();
+ } else if (_vm->_grabCursorSpriteIndex >= 0) {
+ _vm->playGnapImpossible(0, 0);
} else {
- switch (_verbCursor) {
+ switch (_vm->_verbCursor) {
case LOOK_CURSOR:
- if (isFlag(kGFKeysTaken))
- playGnapMoan1(_platX, _platY);
+ if (_vm->isFlag(kGFKeysTaken))
+ _vm->playGnapMoan1(_vm->_platX, _vm->_platY);
else
- 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;
}
}
@@ -159,30 +162,30 @@ void GnapEngine::scene05_run() {
break;
case kHSHaystack:
- if (_gnapActionStatus < 0 && _platypusActionStatus < 0) {
- if (_grabCursorSpriteIndex >= 0) {
- playGnapShowCurrItem(_hotspotsWalkPos[1].x - 2, _hotspotsWalkPos[1].y, 4, 5);
- } else if (isFlag(kGFNeedleTaken)) {
- playGnapImpossible(0, 0);
+ if (_vm->_gnapActionStatus < 0 && _vm->_platypusActionStatus < 0) {
+ if (_vm->_grabCursorSpriteIndex >= 0) {
+ _vm->playGnapShowCurrItem(_vm->_hotspotsWalkPos[1].x - 2, _vm->_hotspotsWalkPos[1].y, 4, 5);
+ } else if (_vm->isFlag(kGFNeedleTaken)) {
+ _vm->playGnapImpossible(0, 0);
} else {
- switch (_verbCursor) {
+ switch (_vm->_verbCursor) {
case LOOK_CURSOR:
- playGnapScratchingHead(_hotspotsWalkPos[1].x, _hotspotsWalkPos[1].y - 1);
+ _vm->playGnapScratchingHead(_vm->_hotspotsWalkPos[1].x, _vm->_hotspotsWalkPos[1].y - 1);
break;
case GRAB_CURSOR:
case TALK_CURSOR:
- playGnapImpossible(0, 0);
+ _vm->playGnapImpossible(0, 0);
break;
case PLAT_CURSOR:
- if (isFlag(kGFPlatypus)) {
- gnapUseDeviceOnPlatypuss();
- if (platypusWalkTo(_hotspotsWalkPos[1].x, _hotspotsWalkPos[1].y, 1, 0x107C2, 1)) {
- _platypusActionStatus = kASPlatSearchHaystack;
- _platypusFacing = kDirUnk4;
+ if (_vm->isFlag(kGFPlatypus)) {
+ _vm->gnapUseDeviceOnPlatypuss();
+ if (_vm->platypusWalkTo(_vm->_hotspotsWalkPos[1].x, _vm->_hotspotsWalkPos[1].y, 1, 0x107C2, 1)) {
+ _vm->_platypusActionStatus = kASPlatSearchHaystack;
+ _vm->_platypusFacing = kDirUnk4;
}
- if (_gnapX == 4 && (_gnapY == 8 || _gnapY == 7))
- gnapWalkStep();
- playGnapIdle(_platX, _platY);
+ if (_vm->_gnapX == 4 && (_vm->_gnapY == 8 || _vm->_gnapY == 7))
+ _vm->gnapWalkStep();
+ _vm->playGnapIdle(_vm->_platX, _vm->_platY);
}
break;
}
@@ -191,31 +194,31 @@ void GnapEngine::scene05_run() {
break;
case kHSChicken:
- if (_gnapActionStatus < 0) {
- if (_grabCursorSpriteIndex == kItemTwig) {
- _gnapIdleFacing = kDirUpRight;
- gnapWalkTo(_hotspotsWalkPos[_sceneClickedHotspot].x, _hotspotsWalkPos[_sceneClickedHotspot].y + 1,
- 0, getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
- _gnapActionStatus = kASUseTwigWithChicken;
- } else if (_grabCursorSpriteIndex >= 0) {
- playGnapShowCurrItem(_hotspotsWalkPos[_sceneClickedHotspot].x, _hotspotsWalkPos[_sceneClickedHotspot].y + 1, 9, 7);
+ if (_vm->_gnapActionStatus < 0) {
+ if (_vm->_grabCursorSpriteIndex == kItemTwig) {
+ _vm->_gnapIdleFacing = kDirUpRight;
+ _vm->gnapWalkTo(_vm->_hotspotsWalkPos[_vm->_sceneClickedHotspot].x, _vm->_hotspotsWalkPos[_vm->_sceneClickedHotspot].y + 1,
+ 0, _vm->getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
+ _vm->_gnapActionStatus = kASUseTwigWithChicken;
+ } else if (_vm->_grabCursorSpriteIndex >= 0) {
+ _vm->playGnapShowCurrItem(_vm->_hotspotsWalkPos[_vm->_sceneClickedHotspot].x, _vm->_hotspotsWalkPos[_vm->_sceneClickedHotspot].y + 1, 9, 7);
} else {
- switch (_verbCursor) {
+ switch (_vm->_verbCursor) {
case LOOK_CURSOR:
- playGnapMoan2(9, 7);
+ _vm->playGnapMoan2(9, 7);
break;
case GRAB_CURSOR:
- _gnapIdleFacing = kDirBottomRight;
- gnapWalkTo(_hotspotsWalkPos[5].x, _hotspotsWalkPos[5].y, 0, getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
- _gnapActionStatus = kASGrabChicken;
+ _vm->_gnapIdleFacing = kDirBottomRight;
+ _vm->gnapWalkTo(_vm->_hotspotsWalkPos[5].x, _vm->_hotspotsWalkPos[5].y, 0, _vm->getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
+ _vm->_gnapActionStatus = kASGrabChicken;
break;
case TALK_CURSOR:
- _gnapIdleFacing = kDirBottomRight;
- gnapWalkTo(_hotspotsWalkPos[5].x, _hotspotsWalkPos[5].y, 0, getGnapSequenceId(gskBrainPulsating, 0, 0) | 0x10000, 1);
- _gnapActionStatus = kASTalkChicken;
+ _vm->_gnapIdleFacing = kDirBottomRight;
+ _vm->gnapWalkTo(_vm->_hotspotsWalkPos[5].x, _vm->_hotspotsWalkPos[5].y, 0, _vm->getGnapSequenceId(gskBrainPulsating, 0, 0) | 0x10000, 1);
+ _vm->_gnapActionStatus = kASTalkChicken;
break;
case PLAT_CURSOR:
- playGnapImpossible(0, 0);
+ _vm->playGnapImpossible(0, 0);
break;
}
}
@@ -223,22 +226,22 @@ void GnapEngine::scene05_run() {
break;
case kHSLadder:
- if (_gnapActionStatus < 0) {
- if (_grabCursorSpriteIndex >= 0) {
- playGnapShowCurrItem(_hotspotsWalkPos[_sceneClickedHotspot].x, _hotspotsWalkPos[_sceneClickedHotspot].y, 2, 5);
+ if (_vm->_gnapActionStatus < 0) {
+ if (_vm->_grabCursorSpriteIndex >= 0) {
+ _vm->playGnapShowCurrItem(_vm->_hotspotsWalkPos[_vm->_sceneClickedHotspot].x, _vm->_hotspotsWalkPos[_vm->_sceneClickedHotspot].y, 2, 5);
} else {
- switch (_verbCursor) {
+ switch (_vm->_verbCursor) {
case LOOK_CURSOR:
- playGnapMoan2(2, 4);
+ _vm->playGnapMoan2(2, 4);
break;
case GRAB_CURSOR:
- _gnapIdleFacing = kDirBottomLeft;
- gnapWalkTo(_hotspotsWalkPos[3].x, _hotspotsWalkPos[3].y, 0, getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
- _gnapActionStatus = kASGrabLadder;
+ _vm->_gnapIdleFacing = kDirBottomLeft;
+ _vm->gnapWalkTo(_vm->_hotspotsWalkPos[3].x, _vm->_hotspotsWalkPos[3].y, 0, _vm->getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
+ _vm->_gnapActionStatus = kASGrabLadder;
break;
case TALK_CURSOR:
case PLAT_CURSOR:
- playGnapImpossible(0, 0);
+ _vm->playGnapImpossible(0, 0);
break;
}
}
@@ -246,35 +249,35 @@ void GnapEngine::scene05_run() {
break;
case kHSPadlock:
- if (isFlag(kGFBarnPadlockOpen)) {
- _isLeavingScene = true;
- gnapWalkTo(_hotspotsWalkPos[2].x - 1, _hotspotsWalkPos[2].y + 1, 0, -1, 1);
- _gnapActionStatus = kASEnterBarn;
- if (_cursorValue == 1)
- _newSceneNum = 6;
+ if (_vm->isFlag(kGFBarnPadlockOpen)) {
+ _vm->_isLeavingScene = true;
+ _vm->gnapWalkTo(_vm->_hotspotsWalkPos[2].x - 1, _vm->_hotspotsWalkPos[2].y + 1, 0, -1, 1);
+ _vm->_gnapActionStatus = kASEnterBarn;
+ if (_vm->_cursorValue == 1)
+ _vm->_newSceneNum = 6;
else
- _newSceneNum = 36;
- } else if (_gnapActionStatus < 0) {
- if (_grabCursorSpriteIndex == kItemNeedle) {
- if (gnapWalkTo(_hotspotsWalkPos[2].x, _hotspotsWalkPos[2].y, 0,
- getGnapSequenceId(gskIdle, _hotspotsWalkPos[2].x, _hotspotsWalkPos[2].y) | 0x10000, 1))
- _gnapActionStatus = kASPickPadlock;
- } else if (_grabCursorSpriteIndex >= 0) {
- playGnapShowCurrItem(_hotspotsWalkPos[2].x, _hotspotsWalkPos[2].y, 7, 4);
+ _vm->_newSceneNum = 36;
+ } else if (_vm->_gnapActionStatus < 0) {
+ if (_vm->_grabCursorSpriteIndex == kItemNeedle) {
+ if (_vm->gnapWalkTo(_vm->_hotspotsWalkPos[2].x, _vm->_hotspotsWalkPos[2].y, 0,
+ _vm->getGnapSequenceId(gskIdle, _vm->_hotspotsWalkPos[2].x, _vm->_hotspotsWalkPos[2].y) | 0x10000, 1))
+ _vm->_gnapActionStatus = kASPickPadlock;
+ } else if (_vm->_grabCursorSpriteIndex >= 0) {
+ _vm->playGnapShowCurrItem(_vm->_hotspotsWalkPos[2].x, _vm->_hotspotsWalkPos[2].y, 7, 4);
} else {
- switch (_verbCursor) {
+ switch (_vm->_verbCursor) {
case LOOK_CURSOR:
- playGnapScratchingHead(7, 4);
+ _vm->playGnapScratchingHead(7, 4);
break;
case GRAB_CURSOR:
- _gnapIdleFacing = kDirUpRight;
- gnapWalkTo(_hotspotsWalkPos[_sceneClickedHotspot].x, _hotspotsWalkPos[_sceneClickedHotspot].y,
- 0, getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
- _gnapActionStatus = kASTryPickPadlock;
+ _vm->_gnapIdleFacing = kDirUpRight;
+ _vm->gnapWalkTo(_vm->_hotspotsWalkPos[_vm->_sceneClickedHotspot].x, _vm->_hotspotsWalkPos[_vm->_sceneClickedHotspot].y,
+ 0, _vm->getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
+ _vm->_gnapActionStatus = kASTryPickPadlock;
break;
case TALK_CURSOR:
case PLAT_CURSOR:
- playGnapImpossible(0, 0);
+ _vm->playGnapImpossible(0, 0);
break;
}
}
@@ -282,23 +285,23 @@ void GnapEngine::scene05_run() {
break;
case kHSExitHouse:
- if (_gnapActionStatus < 0) {
- _isLeavingScene = true;
- gnapWalkTo(_hotspotsWalkPos[4].x, _hotspotsWalkPos[4].y, 0, 0x107AF, 1);
- _gnapActionStatus = kASLeaveScene;
- if (isFlag(kGFPlatypus))
- platypusWalkTo(_hotspotsWalkPos[4].x, _hotspotsWalkPos[4].y + 1, -1, 0x107C7, 1);
- if (_cursorValue == 1)
- _newSceneNum = 4;
+ if (_vm->_gnapActionStatus < 0) {
+ _vm->_isLeavingScene = true;
+ _vm->gnapWalkTo(_vm->_hotspotsWalkPos[4].x, _vm->_hotspotsWalkPos[4].y, 0, 0x107AF, 1);
+ _vm->_gnapActionStatus = kASLeaveScene;
+ if (_vm->isFlag(kGFPlatypus))
+ _vm->platypusWalkTo(_vm->_hotspotsWalkPos[4].x, _vm->_hotspotsWalkPos[4].y + 1, -1, 0x107C7, 1);
+ if (_vm->_cursorValue == 1)
+ _vm->_newSceneNum = 4;
else
- _newSceneNum = 37;
+ _vm->_newSceneNum = 37;
}
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;
case kHSWalkArea3:
@@ -306,162 +309,158 @@ void GnapEngine::scene05_run() {
break;
default:
- if (_mouseClickState._left && _gnapActionStatus < 0) {
- gnapWalkTo(-1, -1, -1, -1, 1);
- _mouseClickState._left = false;
+ if (_vm->_mouseClickState._left && _vm->_gnapActionStatus < 0) {
+ _vm->gnapWalkTo(-1, -1, -1, -1, 1);
+ _vm->_mouseClickState._left = false;
}
break;
}
- scene05_updateAnimations();
+ updateAnimations();
- if (!isSoundPlaying(0x1091C))
- playSound(0x1091C, true);
+ if (!_vm->isSoundPlaying(0x1091C))
+ _vm->playSound(0x1091C, true);
- if (!_isLeavingScene) {
- if (isFlag(kGFPlatypus))
- updatePlatypusIdleSequence();
- updateGnapIdleSequence();
- if (!_timers[5]) {
- _timers[5] = getRandom(20) + 30;
- if (_gnapActionStatus != kASTalkChicken && _s05_nextChickenSequenceId == -1) {
- if (getRandom(4) != 0)
+ if (!_vm->_isLeavingScene) {
+ if (_vm->isFlag(kGFPlatypus))
+ _vm->updatePlatypusIdleSequence();
+ _vm->updateGnapIdleSequence();
+ if (!_vm->_timers[5]) {
+ _vm->_timers[5] = _vm->getRandom(20) + 30;
+ if (_vm->_gnapActionStatus != kASTalkChicken && _s05_nextChickenSequenceId == -1) {
+ if (_vm->getRandom(4) != 0)
_s05_nextChickenSequenceId = 0x142;
else
_s05_nextChickenSequenceId = 0x143;
}
}
- if (!_timers[6]) {
- _timers[6] = getRandom(150) + 300;
- if (_gnapActionStatus < 0)
- _gameSys->insertSequence(0x149, 39, 0, 0, kSeqNone, 0, 0, 0);
+ if (!_vm->_timers[6]) {
+ _vm->_timers[6] = _vm->getRandom(150) + 300;
+ if (_vm->_gnapActionStatus < 0)
+ _vm->_gameSys->insertSequence(0x149, 39, 0, 0, kSeqNone, 0, 0, 0);
}
- playSoundC();
+ _vm->playSoundC();
}
- checkGameKeys();
+ _vm->checkGameKeys();
- if (isKeyStatus1(8)) {
- clearKeyStatus1(8);
- runMenu();
- scene05_updateHotspots();
- _timers[5] = getRandom(20) + 30;
+ if (_vm->isKeyStatus1(8)) {
+ _vm->clearKeyStatus1(8);
+ _vm->runMenu();
+ updateHotspots();
+ _vm->_timers[5] = _vm->getRandom(20) + 30;
}
- gameUpdateTick();
-
+ _vm->gameUpdateTick();
}
-
}
-void GnapEngine::scene05_updateAnimations() {
-
- if (_gameSys->getAnimationStatus(0) == 2) {
- _gameSys->setAnimation(0, 0, 0);
- switch (_gnapActionStatus) {
+void Scene05::updateAnimations() {
+ if (_vm->_gameSys->getAnimationStatus(0) == 2) {
+ _vm->_gameSys->setAnimation(0, 0, 0);
+ switch (_vm->_gnapActionStatus) {
case kASLeaveScene:
- _sceneDone = true;
- _gnapActionStatus = -1;
+ _vm->_sceneDone = true;
+ _vm->_gnapActionStatus = -1;
break;
case kASTryPickPadlock:
- _gameSys->insertSequence(0x148, _gnapId, makeRid(_gnapSequenceDatNum, _gnapSequenceId), _gnapId, kSeqSyncWait, 0, 0, 0);
- _gnapSequenceId = 0x148;
- _gnapSequenceDatNum = 0;
- _gnapActionStatus = -1;
+ _vm->_gameSys->insertSequence(0x148, _vm->_gnapId, makeRid(_vm->_gnapSequenceDatNum, _vm->_gnapSequenceId), _vm->_gnapId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gnapSequenceId = 0x148;
+ _vm->_gnapSequenceDatNum = 0;
+ _vm->_gnapActionStatus = -1;
break;
case kASPickPadlock:
- _gameSys->setAnimation(0x147, _gnapId, 0);
- _gameSys->insertSequence(0x147, _gnapId, makeRid(_gnapSequenceDatNum, _gnapSequenceId), _gnapId, kSeqSyncWait, 0, 0, 0);
- _gnapSequenceId = 0x147;
- _gnapSequenceDatNum = 0;
- setFlag(kGFBarnPadlockOpen);
- setFlag(kGFSceneFlag1);
- setGrabCursorSprite(-1);
- _newSceneNum = 6;
- _timers[2] = 100;
- invRemove(kItemNeedle);
- _gnapActionStatus = kASLeaveScene;
+ _vm->_gameSys->setAnimation(0x147, _vm->_gnapId, 0);
+ _vm->_gameSys->insertSequence(0x147, _vm->_gnapId, makeRid(_vm->_gnapSequenceDatNum, _vm->_gnapSequenceId), _vm->_gnapId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gnapSequenceId = 0x147;
+ _vm->_gnapSequenceDatNum = 0;
+ _vm->setFlag(kGFBarnPadlockOpen);
+ _vm->setFlag(kGFSceneFlag1);
+ _vm->setGrabCursorSprite(-1);
+ _vm->_newSceneNum = 6;
+ _vm->_timers[2] = 100;
+ _vm->invRemove(kItemNeedle);
+ _vm->_gnapActionStatus = kASLeaveScene;
break;
case kASTalkChicken:
_s05_nextChickenSequenceId = 0x144;
- _gnapActionStatus = -1;
+ _vm->_gnapActionStatus = -1;
break;
case kASGrabChicken:
_s05_nextChickenSequenceId = 0x14B;
break;
case kASGrabLadder:
- while (_gameSys->isSequenceActive(0x149, 39))
- gameUpdateTick();
- _gameSys->insertSequence(0x14E, _gnapId + 1, 0, 0, kSeqNone, 0, 0, 0);
- _gameSys->insertSequence(0x14D, _gnapId, makeRid(_gnapSequenceDatNum, _gnapSequenceId), _gnapId, kSeqSyncWait, 0, 0, 0);
- _gnapSequenceId = 0x14D;
- _gnapSequenceDatNum = 0;
- _timers[2] = 200;
- _timers[6] = 300;
- _gnapActionStatus = -1;
+ while (_vm->_gameSys->isSequenceActive(0x149, 39))
+ _vm->gameUpdateTick();
+ _vm->_gameSys->insertSequence(0x14E, _vm->_gnapId + 1, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0x14D, _vm->_gnapId, makeRid(_vm->_gnapSequenceDatNum, _vm->_gnapSequenceId), _vm->_gnapId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gnapSequenceId = 0x14D;
+ _vm->_gnapSequenceDatNum = 0;
+ _vm->_timers[2] = 200;
+ _vm->_timers[6] = 300;
+ _vm->_gnapActionStatus = -1;
break;
case kASEnterBarn:
- _gameSys->insertSequence(0x107B1, 1,
- makeRid(_gnapSequenceDatNum, _gnapSequenceId), _gnapId,
- kSeqSyncWait, 0, 75 * _gnapX - _gnapGridX, 48 * _gnapY - _gnapGridY);
- _gameSys->setAnimation(0x107B1, 1, 0);
- _gnapActionStatus = kASLeaveScene;
+ _vm->_gameSys->insertSequence(0x107B1, 1,
+ makeRid(_vm->_gnapSequenceDatNum, _vm->_gnapSequenceId), _vm->_gnapId,
+ kSeqSyncWait, 0, 75 * _vm->_gnapX - _vm->_gnapGridX, 48 * _vm->_gnapY - _vm->_gnapGridY);
+ _vm->_gameSys->setAnimation(0x107B1, 1, 0);
+ _vm->_gnapActionStatus = kASLeaveScene;
break;
case kASUseTwigWithChicken:
- playGnapShowItem(5, 0, 0);
+ _vm->playGnapShowItem(5, 0, 0);
_s05_nextChickenSequenceId = 0x14F;
- _gnapActionStatus = -1;
+ _vm->_gnapActionStatus = -1;
break;
}
}
- if (_gameSys->getAnimationStatus(1) == 2) {
- if (_platypusSequenceId == 0x146) {
- _platX = 4;
- _platY = 8;
- _gameSys->insertSequence(0x107C1, 160, 0x146, 256, kSeqSyncWait, 0, 300 - _platGridX, 384 - _platGridY);
- _platypusSequenceId = 0x7C1;
- _platypusSequenceDatNum = 1;
- _platypusId = 20 * _platY;
- invAdd(kItemNeedle);
- setFlag(kGFNeedleTaken);
- setGrabCursorSprite(kItemNeedle);
- showCursor();
- _timers[1] = 30;
- _platypusActionStatus = -1;
+ if (_vm->_gameSys->getAnimationStatus(1) == 2) {
+ if (_vm->_platypusSequenceId == 0x146) {
+ _vm->_platX = 4;
+ _vm->_platY = 8;
+ _vm->_gameSys->insertSequence(0x107C1, 160, 0x146, 256, kSeqSyncWait, 0, 300 - _vm->_platGridX, 384 - _vm->_platGridY);
+ _vm->_platypusSequenceId = 0x7C1;
+ _vm->_platypusSequenceDatNum = 1;
+ _vm->_platypusId = 20 * _vm->_platY;
+ _vm->invAdd(kItemNeedle);
+ _vm->setFlag(kGFNeedleTaken);
+ _vm->setGrabCursorSprite(kItemNeedle);
+ _vm->showCursor();
+ _vm->_timers[1] = 30;
+ _vm->_platypusActionStatus = -1;
}
- if (_platypusActionStatus == kASPlatSearchHaystack) {
- _gameSys->setAnimation(0, 0, 1);
- _gameSys->insertSequence(0x145, _platypusId, _platypusSequenceId | (_platypusSequenceDatNum << 16), _platypusId, kSeqSyncWait, 0, 0, 0);
- _gameSys->insertSequence(0x146, 256, 0x145, _platypusId, kSeqSyncWait, 0, 0, 0);
- hideCursor();
- setGrabCursorSprite(-1);
- _platypusSequenceId = 0x146;
- _platypusSequenceDatNum = 0;
- _gameSys->setAnimation(0x146, 256, 1);
- _timers[1] = 300;
+ if (_vm->_platypusActionStatus == kASPlatSearchHaystack) {
+ _vm->_gameSys->setAnimation(0, 0, 1);
+ _vm->_gameSys->insertSequence(0x145, _vm->_platypusId, _vm->_platypusSequenceId | (_vm->_platypusSequenceDatNum << 16), _vm->_platypusId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0x146, 256, 0x145, _vm->_platypusId, kSeqSyncWait, 0, 0, 0);
+ _vm->hideCursor();
+ _vm->setGrabCursorSprite(-1);
+ _vm->_platypusSequenceId = 0x146;
+ _vm->_platypusSequenceDatNum = 0;
+ _vm->_gameSys->setAnimation(0x146, 256, 1);
+ _vm->_timers[1] = 300;
}
}
- if (_gameSys->getAnimationStatus(3) == 2) {
+ if (_vm->_gameSys->getAnimationStatus(3) == 2) {
if (_s05_nextChickenSequenceId == 0x14B) {
- _gameSys->setAnimation(_s05_nextChickenSequenceId, 100, 3);
- _gameSys->insertSequence(_s05_nextChickenSequenceId, 100, _s05_currChickenSequenceId, 100, kSeqSyncWait, 0, 0, 0);
- _gameSys->insertSequence(0x14C, _gnapId, makeRid(_gnapSequenceDatNum, _gnapSequenceId), _gnapId, kSeqSyncWait, 0, 0, 0);
- _gnapSequenceDatNum = 0;
- _gnapSequenceId = 0x14C;
+ _vm->_gameSys->setAnimation(_s05_nextChickenSequenceId, 100, 3);
+ _vm->_gameSys->insertSequence(_s05_nextChickenSequenceId, 100, _s05_currChickenSequenceId, 100, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0x14C, _vm->_gnapId, makeRid(_vm->_gnapSequenceDatNum, _vm->_gnapSequenceId), _vm->_gnapId, kSeqSyncWait, 0, 0, 0);
+ _vm->_gnapSequenceDatNum = 0;
+ _vm->_gnapSequenceId = 0x14C;
_s05_currChickenSequenceId = _s05_nextChickenSequenceId;
_s05_nextChickenSequenceId = -1;
- _gnapActionStatus = -1;
+ _vm->_gnapActionStatus = -1;
} else if (_s05_nextChickenSequenceId != -1) {
- _gameSys->setAnimation(_s05_nextChickenSequenceId, 100, 3);
- _gameSys->insertSequence(_s05_nextChickenSequenceId, 100, _s05_currChickenSequenceId, 100, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->setAnimation(_s05_nextChickenSequenceId, 100, 3);
+ _vm->_gameSys->insertSequence(_s05_nextChickenSequenceId, 100, _s05_currChickenSequenceId, 100, kSeqSyncWait, 0, 0, 0);
_s05_currChickenSequenceId = _s05_nextChickenSequenceId;
_s05_nextChickenSequenceId = -1;
}
}
-
}
} // End of namespace Gnap
diff --git a/engines/gnap/scenes/scene05.h b/engines/gnap/scenes/scene05.h
new file mode 100644
index 0000000000..f79adc0e41
--- /dev/null
+++ b/engines/gnap/scenes/scene05.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_SCENE05_H
+#define GNAP_SCENE05_H
+
+#include "gnap/debugger.h"
+#include "gnap/scenes/scenecore.h"
+
+namespace Gnap {
+
+class GnapEngine;
+
+class Scene05: public Scene {
+public:
+ Scene05(GnapEngine *vm);
+ ~Scene05() {}
+
+ virtual int init();
+ virtual void updateHotspots();
+ virtual void run();
+ virtual void updateAnimations();
+
+private:
+ int _s05_nextChickenSequenceId;
+ int _s05_currChickenSequenceId;
+};
+
+} // End of namespace Gnap
+
+#endif // GNAP_SCENE05_H
diff --git a/engines/gnap/scenes/scenecore.cpp b/engines/gnap/scenes/scenecore.cpp
index 3837b7caf9..81834191dd 100644
--- a/engines/gnap/scenes/scenecore.cpp
+++ b/engines/gnap/scenes/scenecore.cpp
@@ -30,6 +30,7 @@
#include "gnap/scenes/scene02.h"
#include "gnap/scenes/scene03.h"
#include "gnap/scenes/scene04.h"
+#include "gnap/scenes/scene05.h"
namespace Gnap {
@@ -71,8 +72,9 @@ int GnapEngine::initSceneLogic() {
initSceneGrid(21, 146, 11, 10);
break;
case 5:
- backgroundId = scene05_init();
- scene05_updateHotspots();
+ _scene = new Scene05(this);
+ backgroundId = _scene->init();
+ _scene->updateHotspots();
_gameSys->setScaleValues(0, 500, 1, 1000);
initSceneGrid(21, 146, 11, 10);
break;
@@ -251,8 +253,9 @@ int GnapEngine::initSceneLogic() {
initSceneGrid(21, 146, 11, 10);
break;
case 35:
- backgroundId = scene05_init();
- scene05_updateHotspots();
+ _scene = new Scene05(this);
+ backgroundId = _scene->init();
+ _scene->updateHotspots();
_gameSys->setScaleValues(0, 500, 1, 1000);
initSceneGrid(21, 146, 11, 10);
break;
@@ -388,7 +391,8 @@ void GnapEngine::runSceneLogic() {
_newSceneNum = 4;
break;
case 5:
- scene05_run();
+ _scene->run();
+ delete _scene;
if (_newSceneNum == 55)
_newSceneNum = 4;
break;
@@ -540,7 +544,8 @@ void GnapEngine::runSceneLogic() {
_newSceneNum = 37;
break;
case 35:
- scene05_run();
+ _scene->run();
+ delete _scene;
if (_newSceneNum == 55)
_newSceneNum = 37;
break;