aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2016-04-20 21:19:02 +0200
committerEugene Sandulenko2016-05-10 09:54:21 +0200
commit0f43db94a201864ea596e82660831f9ea634dd42 (patch)
treead9401daf14c002326e48c1ba787ccc5a1a61892 /engines
parentaea51e0d40a0be2a724e7a6650382b7157b01952 (diff)
downloadscummvm-rg350-0f43db94a201864ea596e82660831f9ea634dd42.tar.gz
scummvm-rg350-0f43db94a201864ea596e82660831f9ea634dd42.tar.bz2
scummvm-rg350-0f43db94a201864ea596e82660831f9ea634dd42.zip
GNAP: Refactor scene 7
Diffstat (limited to 'engines')
-rw-r--r--engines/gnap/gnap.h6
-rw-r--r--engines/gnap/scenes/scene07.cpp273
-rw-r--r--engines/gnap/scenes/scene07.h48
-rw-r--r--engines/gnap/scenes/scenecore.cpp9
4 files changed, 189 insertions, 147 deletions
diff --git a/engines/gnap/gnap.h b/engines/gnap/gnap.h
index 43b2f6ae05..651d24e227 100644
--- a/engines/gnap/gnap.h
+++ b/engines/gnap/gnap.h
@@ -603,12 +603,6 @@ public:
void sceneXX_playRandomSound(int timerIndex);
void playSequences(int fullScreenSpriteId, int sequenceId1, int sequenceId2, int sequenceId3);
- // Scene 7
- int scene07_init();
- void scene07_updateHotspots();
- void scene07_run();
- void scene07_updateAnimations();
-
// Scene 8
int _s08_nextDogSequenceId, _s08_currDogSequenceId;
int _s08_nextManSequenceId, _s08_currManSequenceId;
diff --git a/engines/gnap/scenes/scene07.cpp b/engines/gnap/scenes/scene07.cpp
index dab9051114..c94408297e 100644
--- a/engines/gnap/scenes/scene07.cpp
+++ b/engines/gnap/scenes/scene07.cpp
@@ -24,6 +24,8 @@
#include "gnap/gamesys.h"
#include "gnap/resource.h"
+#include "gnap/scenes/scene07.h"
+
namespace Gnap {
enum {
@@ -41,88 +43,89 @@ enum {
kASLeaveScene = 1
};
-int GnapEngine::scene07_init() {
+Scene07::Scene07(GnapEngine *vm) : Scene(vm) {
+}
+
+int Scene07::init() {
return 0x92;
}
-void GnapEngine::scene07_updateHotspots() {
- setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
- setHotspot(kHSExitHouse, 700, 125, 799, 290, SF_EXIT_NE_CURSOR);
- setHotspot(kHSDice, 200, 290, 270, 360, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
- setHotspot(kHSWalkArea1, 0, 0, 325, 445);
- setHotspot(kHSWalkArea2, 325, 0, 799, 445, _isLeavingScene ? SF_WALKABLE : SF_NONE);
- setHotspot(kHSWalkArea3, 160, 0, 325, 495);
- setDeviceHotspot(kHSDevice, -1, -1, -1, -1);
- if (isFlag(kGFPlatypus))
- _hotspots[kHSDice]._flags = SF_DISABLED;
- _hotspotsCount = 7;
+void Scene07::updateHotspots() {
+ _vm->setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
+ _vm->setHotspot(kHSExitHouse, 700, 125, 799, 290, SF_EXIT_NE_CURSOR);
+ _vm->setHotspot(kHSDice, 200, 290, 270, 360, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
+ _vm->setHotspot(kHSWalkArea1, 0, 0, 325, 445);
+ _vm->setHotspot(kHSWalkArea2, 325, 0, 799, 445, _vm->_isLeavingScene ? SF_WALKABLE : SF_NONE);
+ _vm->setHotspot(kHSWalkArea3, 160, 0, 325, 495);
+ _vm->setDeviceHotspot(kHSDevice, -1, -1, -1, -1);
+ if (_vm->isFlag(kGFPlatypus))
+ _vm->_hotspots[kHSDice]._flags = SF_DISABLED;
+ _vm->_hotspotsCount = 7;
}
-void GnapEngine::scene07_run() {
- queueInsertDeviceIcon();
- _gameSys->insertSequence(0x8C, 1, 0, 0, kSeqLoop, 0, 0, 0);
- _gameSys->insertSequence(0x90, 1, 0, 0, kSeqLoop, 0, 0, 0);
+void Scene07::run() {
+ _vm->queueInsertDeviceIcon();
+ _vm->_gameSys->insertSequence(0x8C, 1, 0, 0, kSeqLoop, 0, 0, 0);
+ _vm->_gameSys->insertSequence(0x90, 1, 0, 0, kSeqLoop, 0, 0, 0);
- invRemove(kItemGas);
- invRemove(kItemNeedle);
+ _vm->invRemove(kItemGas);
+ _vm->invRemove(kItemNeedle);
- if (!isFlag(kGFPlatypus))
- _gameSys->insertSequence(0x8D, 1, 0, 0, kSeqNone, 0, 0, 0);
+ if (!_vm->isFlag(kGFPlatypus))
+ _vm->_gameSys->insertSequence(0x8D, 1, 0, 0, kSeqNone, 0, 0, 0);
- if (_prevSceneNum == 8) {
- initGnapPos(7, 7, kDirBottomLeft);
- initPlatypusPos(9, 7, kDirUnk4);
- endSceneInit();
+ if (_vm->_prevSceneNum == 8) {
+ _vm->initGnapPos(7, 7, kDirBottomLeft);
+ _vm->initPlatypusPos(9, 7, kDirUnk4);
+ _vm->endSceneInit();
} else {
- _gnapX = 6;
- _gnapY = 7;
- _gnapId = 140;
- _gnapSequenceId = 0x8F;
- _gnapSequenceDatNum = 0;
- _gnapIdleFacing = kDirBottomRight;
- _gameSys->insertSequence(0x8F, 140, 0, 0, kSeqNone, 0, 0, 0);
- _gameSys->setAnimation(makeRid(_gnapSequenceDatNum, _gnapSequenceId), _gnapId, 0);
- _gnapActionStatus = kASWait;
- _platX = 3;
- _platY = 8;
- _platypusId = 160;
- _platypusSequenceId = 0x91;
- _platypusSequenceDatNum = 0;
- _platypusFacing = kDirNone;
- _gameSys->insertSequence(0x91, 160, 0, 0, kSeqNone, 0, 0, 0);
- endSceneInit();
+ _vm->_gnapX = 6;
+ _vm->_gnapY = 7;
+ _vm->_gnapId = 140;
+ _vm->_gnapSequenceId = 0x8F;
+ _vm->_gnapSequenceDatNum = 0;
+ _vm->_gnapIdleFacing = kDirBottomRight;
+ _vm->_gameSys->insertSequence(0x8F, 140, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->_gameSys->setAnimation(makeRid(_vm->_gnapSequenceDatNum, _vm->_gnapSequenceId), _vm->_gnapId, 0);
+ _vm->_gnapActionStatus = kASWait;
+ _vm->_platX = 3;
+ _vm->_platY = 8;
+ _vm->_platypusId = 160;
+ _vm->_platypusSequenceId = 0x91;
+ _vm->_platypusSequenceDatNum = 0;
+ _vm->_platypusFacing = kDirNone;
+ _vm->_gameSys->insertSequence(0x91, 160, 0, 0, kSeqNone, 0, 0, 0);
+ _vm->endSceneInit();
}
- _timers[3] = 600;
- _timers[4] = getRandom(40) + 50;
-
- while (!_sceneDone) {
-
- if (!isSoundPlaying(0x10919))
- playSound(0x10919, true);
+ _vm->_timers[3] = 600;
+ _vm->_timers[4] = _vm->getRandom(40) + 50;
- if (testWalk(0, 1, 8, 7, 6, 7))
- scene07_updateHotspots();
+ while (!_vm->_sceneDone) {
+ if (!_vm->isSoundPlaying(0x10919))
+ _vm->playSound(0x10919, true);
- updateMouseCursor();
- updateCursorByHotspot();
+ if (_vm->testWalk(0, 1, 8, 7, 6, 7))
+ updateHotspots();
- _sceneClickedHotspot = getClickedHotspotId();
- updateGrabCursorSprite(0, 0);
+ _vm->updateMouseCursor();
+ _vm->updateCursorByHotspot();
- switch (_sceneClickedHotspot) {
+ _vm->_sceneClickedHotspot = _vm->getClickedHotspotId();
+ _vm->updateGrabCursorSprite(0, 0);
+ switch (_vm->_sceneClickedHotspot) {
case kHSPlatypus:
- switch (_verbCursor) {
+ switch (_vm->_verbCursor) {
case LOOK_CURSOR:
- playGnapMoan1(_platX, _platY);
+ _vm->playGnapMoan1(_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:
break;
@@ -130,53 +133,53 @@ void GnapEngine::scene07_run() {
break;
case kHSExitHouse:
- _isLeavingScene = true;
- if (_gnapX > 8)
- gnapWalkTo(_gnapX, 7, 0, 0x107AD, 1);
+ _vm->_isLeavingScene = true;
+ if (_vm->_gnapX > 8)
+ _vm->gnapWalkTo(_vm->_gnapX, 7, 0, 0x107AD, 1);
else
- gnapWalkTo(8, 7, 0, 0x107AD, 1);
- _gnapActionStatus = kASLeaveScene;
+ _vm->gnapWalkTo(8, 7, 0, 0x107AD, 1);
+ _vm->_gnapActionStatus = kASLeaveScene;
break;
case kHSDice:
- if (_grabCursorSpriteIndex >= 0) {
- playGnapShowCurrItem(4, 8, 3, 3);
+ if (_vm->_grabCursorSpriteIndex >= 0) {
+ _vm->playGnapShowCurrItem(4, 8, 3, 3);
} else {
- switch (_verbCursor) {
+ switch (_vm->_verbCursor) {
case LOOK_CURSOR:
break;
case GRAB_CURSOR:
- setFlag(kGFPlatypus);
- invAdd(kItemDice);
- scene07_updateHotspots();
- playGnapPullOutDevice(3, 3);
- _gameSys->setAnimation(0x8E, 1, 2);
- _gameSys->insertSequence(0x8E, 1, 141, 1, kSeqSyncWait, 0, 0, 0);
- _gameSys->insertSequence(getGnapSequenceId(gskUseDevice, 0, 0) | 0x10000, _gnapId,
- makeRid(_gnapSequenceDatNum, _gnapSequenceId), _gnapId,
- kSeqSyncWait, 0, 75 * _gnapX - _gnapGridX, 48 * _gnapY - _gnapGridY);
- _gnapSequenceId = getGnapSequenceId(gskUseDevice, 0, 0);
- _gnapSequenceDatNum = 1;
+ _vm->setFlag(kGFPlatypus);
+ _vm->invAdd(kItemDice);
+ updateHotspots();
+ _vm->playGnapPullOutDevice(3, 3);
+ _vm->_gameSys->setAnimation(0x8E, 1, 2);
+ _vm->_gameSys->insertSequence(0x8E, 1, 141, 1, kSeqSyncWait, 0, 0, 0);
+ _vm->_gameSys->insertSequence(_vm->getGnapSequenceId(gskUseDevice, 0, 0) | 0x10000, _vm->_gnapId,
+ makeRid(_vm->_gnapSequenceDatNum, _vm->_gnapSequenceId), _vm->_gnapId,
+ kSeqSyncWait, 0, 75 * _vm->_gnapX - _vm->_gnapGridX, 48 * _vm->_gnapY - _vm->_gnapGridY);
+ _vm->_gnapSequenceId = _vm->getGnapSequenceId(gskUseDevice, 0, 0);
+ _vm->_gnapSequenceDatNum = 1;
break;
case TALK_CURSOR:
case PLAT_CURSOR:
- playGnapImpossible(0, 0);
+ _vm->playGnapImpossible(0, 0);
break;
}
}
break;
case kHSDevice:
- if (_gnapActionStatus < 0) {
- runMenu();
- scene07_updateHotspots();
- _timers[4] = getRandom(40) + 50;
+ if (_vm->_gnapActionStatus < 0) {
+ _vm->runMenu();
+ updateHotspots();
+ _vm->_timers[4] = _vm->getRandom(40) + 50;
}
break;
case kHSWalkArea1:
case kHSWalkArea2:
- gnapWalkTo(-1, -1, -1, -1, 1);
+ _vm->gnapWalkTo(-1, -1, -1, -1, 1);
break;
case kHSWalkArea3:
@@ -184,91 +187,85 @@ void GnapEngine::scene07_run() {
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;
-
}
- scene07_updateAnimations();
+ updateAnimations();
- if (!_isLeavingScene) {
- updateGnapIdleSequence();
- if (_platypusActionStatus < 0 && _gnapActionStatus < 0) {
- if (_timers[0]) {
- if (!_timers[1]) {
- _timers[1] = getRandom(20) + 30;
- int _gnapRandomValue = getRandom(20);
+ if (!_vm->_isLeavingScene) {
+ _vm->updateGnapIdleSequence();
+ if (_vm->_platypusActionStatus < 0 && _vm->_gnapActionStatus < 0) {
+ if (_vm->_timers[0]) {
+ if (!_vm->_timers[1]) {
+ _vm->_timers[1] = _vm->getRandom(20) + 30;
+ int gnapRandomValue = _vm->getRandom(20);
// TODO Cleanup
- if (_platypusFacing != kDirNone) {
- if (_gnapRandomValue != 0 || _platypusSequenceId != 0x7CA) {
- if (_gnapRandomValue != 1 || _platypusSequenceId != 0x7CA) {
- if (_platY == 9)
- playPlatypusSequence(0x107CA);
+ if (_vm->_platypusFacing != kDirNone) {
+ if (gnapRandomValue != 0 || _vm->_platypusSequenceId != 0x7CA) {
+ if (gnapRandomValue != 1 || _vm->_platypusSequenceId != 0x7CA) {
+ if (_vm->_platY == 9)
+ _vm->playPlatypusSequence(0x107CA);
} else {
- playPlatypusSequence(0x10845);
+ _vm->playPlatypusSequence(0x10845);
}
} else {
- playPlatypusSequence(0x107CC);
+ _vm->playPlatypusSequence(0x107CC);
}
- } else if (_gnapRandomValue != 0 || _platypusSequenceId != 0x7C9) {
- if (_gnapRandomValue != 1 || _platypusSequenceId != 0x7C9) {
- if (_platY == 9)
- playPlatypusSequence(0x107C9);
+ } else if (gnapRandomValue != 0 || _vm->_platypusSequenceId != 0x7C9) {
+ if (gnapRandomValue != 1 || _vm->_platypusSequenceId != 0x7C9) {
+ if (_vm->_platY == 9)
+ _vm->playPlatypusSequence(0x107C9);
} else {
- playPlatypusSequence(0x10844);
+ _vm->playPlatypusSequence(0x10844);
}
} else {
- playPlatypusSequence(0x107CB);
+ _vm->playPlatypusSequence(0x107CB);
}
- _gameSys->setAnimation(_platypusSequenceId | (_platypusSequenceDatNum << 16), _platypusId, 1);
+ _vm->_gameSys->setAnimation(_vm->_platypusSequenceId | (_vm->_platypusSequenceDatNum << 16), _vm->_platypusId, 1);
}
} else {
- _timers[0] = getRandom(75) + 75;
- platypusMakeRoom();
+ _vm->_timers[0] = _vm->getRandom(75) + 75;
+ _vm->platypusMakeRoom();
}
} else {
- _timers[0] = 100;
- _timers[1] = 35;
+ _vm->_timers[0] = 100;
+ _vm->_timers[1] = 35;
}
- sceneXX_playRandomSound(4);
+ _vm->sceneXX_playRandomSound(4);
}
- checkGameKeys();
+ _vm->checkGameKeys();
- if (isKeyStatus1(8)) {
- clearKeyStatus1(8);
- runMenu();
- scene07_updateHotspots();
- _timers[4] = getRandom(40) + 50;
+ if (_vm->isKeyStatus1(8)) {
+ _vm->clearKeyStatus1(8);
+ _vm->runMenu();
+ updateHotspots();
+ _vm->_timers[4] = _vm->getRandom(40) + 50;
}
-
- gameUpdateTick();
-
+ _vm->gameUpdateTick();
}
-
}
-void GnapEngine::scene07_updateAnimations() {
-
- if (_gameSys->getAnimationStatus(0) == 2) {
- _gameSys->setAnimation(0, 0, 0);
- switch (_gnapActionStatus) {
+void Scene07::updateAnimations() {
+ if (_vm->_gameSys->getAnimationStatus(0) == 2) {
+ _vm->_gameSys->setAnimation(0, 0, 0);
+ switch (_vm->_gnapActionStatus) {
case kASLeaveScene:
- _newSceneNum = 8;
- _sceneDone = true;
+ _vm->_newSceneNum = 8;
+ _vm->_sceneDone = true;
break;
}
- _gnapActionStatus = -1;
+ _vm->_gnapActionStatus = -1;
}
- if (_gameSys->getAnimationStatus(2) == 2) {
- _gameSys->setAnimation(0, 0, 2);
- setGrabCursorSprite(kItemDice);
+ if (_vm->_gameSys->getAnimationStatus(2) == 2) {
+ _vm->_gameSys->setAnimation(0, 0, 2);
+ _vm->setGrabCursorSprite(kItemDice);
}
-
}
} // End of namespace Gnap
diff --git a/engines/gnap/scenes/scene07.h b/engines/gnap/scenes/scene07.h
new file mode 100644
index 0000000000..08fdab2f3f
--- /dev/null
+++ b/engines/gnap/scenes/scene07.h
@@ -0,0 +1,48 @@
+/* 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_SCENE07_H
+#define GNAP_SCENE07_H
+
+#include "gnap/debugger.h"
+#include "gnap/scenes/scenecore.h"
+
+namespace Gnap {
+
+class GnapEngine;
+
+class Scene07: public Scene {
+public:
+ Scene07(GnapEngine *vm);
+ ~Scene07() {}
+
+ virtual int init();
+ virtual void updateHotspots();
+ virtual void run();
+ virtual void updateAnimations();
+
+private:
+};
+
+} // End of namespace Gnap
+
+#endif // GNAP_SCENE05_H
diff --git a/engines/gnap/scenes/scenecore.cpp b/engines/gnap/scenes/scenecore.cpp
index f5d82ce512..ba14f1260e 100644
--- a/engines/gnap/scenes/scenecore.cpp
+++ b/engines/gnap/scenes/scenecore.cpp
@@ -32,6 +32,7 @@
#include "gnap/scenes/scene04.h"
#include "gnap/scenes/scene05.h"
#include "gnap/scenes/scene06.h"
+#include "gnap/scenes/scene07.h"
namespace Gnap {
@@ -87,8 +88,9 @@ int GnapEngine::initSceneLogic() {
initSceneGrid(21, 146, 11, 10);
break;
case 7:
- backgroundId = scene07_init();
- scene07_updateHotspots();
+ _scene = new Scene07(this);
+ backgroundId = _scene->init();
+ _scene->updateHotspots();
_gameSys->setScaleValues(0, 500, 1, 1000);
initSceneGrid(21, 146, 11, 10);
break;
@@ -406,7 +408,8 @@ void GnapEngine::runSceneLogic() {
_newSceneNum = 4;
break;
case 7:
- scene07_run();
+ _scene->run();
+ delete _scene;
if (_newSceneNum == 55)
_newSceneNum = 8;
break;