GNAP: Refactor scenes 22 & 23

This commit is contained in:
Strangerke 2016-04-23 11:34:39 +02:00 committed by Eugene Sandulenko
parent 14ec2e9699
commit d1e7c9f594
7 changed files with 358 additions and 274 deletions

View File

@ -2018,13 +2018,9 @@ void GnapEngine::initPlatypusPos(int gridX, int gridY, Facing facing) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void GnapEngine::initGlobalSceneVars() { void GnapEngine::initGlobalSceneVars() {
// Scene 18 // Shared by scenes 17 && 18
_s18_garbageCanPos = 8; _s18_garbageCanPos = 8;
// Scene 22
_s22_caughtBefore = false;
_s22_cashierCtr = 3;
// Scene 31 // Scene 31
_s31_beerGuyDistracted = false; _s31_beerGuyDistracted = false;
_s31_clerkMeasureMaxCtr = 3; _s31_clerkMeasureMaxCtr = 3;

View File

@ -606,22 +606,6 @@ public:
// Scene 18 // Scene 18
int _s18_garbageCanPos; int _s18_garbageCanPos;
// Scene 22
int _s22_currCashierSequenceId, _s22_nextCashierSequenceId;
bool _s22_caughtBefore;
int _s22_cashierCtr;
int scene22_init();
void scene22_updateHotspots();
void scene22_run();
void scene22_updateAnimations();
// Scene 23
int _s23_currStoreClerkSequenceId, _s23_nextStoreClerkSequenceId;
int scene23_init();
void scene23_updateHotspots();
void scene23_run();
void scene23_updateAnimations();
// Scene 24 // Scene 24
int _s24_currWomanSequenceId, _s24_nextWomanSequenceId; int _s24_currWomanSequenceId, _s24_nextWomanSequenceId;
int _s24_boySequenceId; int _s24_boySequenceId;

View File

@ -23,6 +23,7 @@
#include "gnap/gnap.h" #include "gnap/gnap.h"
#include "gnap/gamesys.h" #include "gnap/gamesys.h"
#include "gnap/resource.h" #include "gnap/resource.h"
#include "gnap/scenes/scene22.h"
namespace Gnap { namespace Gnap {
@ -41,53 +42,57 @@ enum {
kASTalkCashier = 1 kASTalkCashier = 1
}; };
int GnapEngine::scene22_init() { Scene22::Scene22(GnapEngine *vm) : Scene(vm) {
_s22_caughtBefore = false;
_s22_cashierCtr = 3;
}
int Scene22::init() {
return 0x5E; return 0x5E;
} }
void GnapEngine::scene22_updateHotspots() { void Scene22::updateHotspots() {
setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR); _vm->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); _vm->setHotspot(kHSExitOutsideGrubCity, 0, 180, 184, 472, SF_EXIT_L_CURSOR, 3, 6);
setHotspot(kHSExitBackGrubCity, 785, 405, 800, 585, SF_EXIT_R_CURSOR, 11, 9); _vm->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); _vm->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); _vm->setHotspot(kHSWalkArea1, 553, 0, 800, 542);
setHotspot(kHSWalkArea2, 0, 0, 552, 488); _vm->setHotspot(kHSWalkArea2, 0, 0, 552, 488);
setDeviceHotspot(kHSDevice, -1, -1, -1, -1); _vm->setDeviceHotspot(kHSDevice, -1, -1, -1, -1);
_hotspotsCount = 7; _vm->_hotspotsCount = 7;
} }
void GnapEngine::scene22_run() { void Scene22::run() {
_vm->_gameSys->insertSequence(0x5D, 254, 0, 0, kSeqNone, 0, 0, 0);
_gameSys->insertSequence(0x5D, 254, 0, 0, kSeqNone, 0, 0, 0);
_s22_currCashierSequenceId = 0x59; _s22_currCashierSequenceId = 0x59;
_s22_nextCashierSequenceId = -1; _s22_nextCashierSequenceId = -1;
_gameSys->setAnimation(0x59, 1, 3); _vm->_gameSys->setAnimation(0x59, 1, 3);
_gameSys->insertSequence(_s22_currCashierSequenceId, 1, 0, 0, kSeqNone, 0, 0, 0); _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) { if (_vm->_prevSceneNum == 20) {
initGnapPos(2, 8, kDirBottomRight); _vm->initGnapPos(2, 8, kDirBottomRight);
initPlatypusPos(1, 8, kDirNone); _vm->initPlatypusPos(1, 8, kDirNone);
endSceneInit(); _vm->endSceneInit();
} else { } else {
initGnapPos(11, _hotspotsWalkPos[kHSExitBackGrubCity].y, kDirBottomRight); _vm->initGnapPos(11, _vm->_hotspotsWalkPos[kHSExitBackGrubCity].y, kDirBottomRight);
initPlatypusPos(11, _hotspotsWalkPos[kHSExitBackGrubCity].y + 1, kDirNone); _vm->initPlatypusPos(11, _vm->_hotspotsWalkPos[kHSExitBackGrubCity].y + 1, kDirNone);
endSceneInit(); _vm->endSceneInit();
gnapWalkTo(8, 8, -1, 0x107B9, 1); _vm->gnapWalkTo(8, 8, -1, 0x107B9, 1);
platypusWalkTo(9, 8, -1, 0x107C2, 1); _vm->platypusWalkTo(9, 8, -1, 0x107C2, 1);
} }
if (isFlag(kGFSceneFlag1)) { if (_vm->isFlag(kGFSceneFlag1)) {
int storeDetectiveSeqId; int storeDetectiveSeqId;
setGrabCursorSprite(-1); _vm->setGrabCursorSprite(-1);
invRemove(kItemCereals); _vm->invRemove(kItemCereals);
if (_s22_caughtBefore) { if (_s22_caughtBefore) {
switch (getRandom(3)) { switch (_vm->getRandom(3)) {
case 0: case 0:
storeDetectiveSeqId = 0x55; storeDetectiveSeqId = 0x55;
break; break;
@ -102,58 +107,56 @@ void GnapEngine::scene22_run() {
_s22_caughtBefore = true; _s22_caughtBefore = true;
storeDetectiveSeqId = 0x54; storeDetectiveSeqId = 0x54;
} }
_gameSys->waitForUpdate(); _vm->_gameSys->waitForUpdate();
_gameSys->requestClear1(); _vm->_gameSys->requestClear1();
_gameSys->drawSpriteToBackground(0, 0, 0x44); _vm->_gameSys->drawSpriteToBackground(0, 0, 0x44);
_gameSys->setAnimation(storeDetectiveSeqId, 256, 4); _vm->_gameSys->setAnimation(storeDetectiveSeqId, 256, 4);
_gameSys->insertSequence(storeDetectiveSeqId, 256, 0, 0, kSeqNone, 0, 0, 0); _vm->_gameSys->insertSequence(storeDetectiveSeqId, 256, 0, 0, kSeqNone, 0, 0, 0);
while (_gameSys->getAnimationStatus(4) != 2) { while (_vm->_gameSys->getAnimationStatus(4) != 2) {
gameUpdateTick(); _vm->gameUpdateTick();
} }
_sceneDone = true; _vm->_sceneDone = true;
_newSceneNum = 20; _vm->_newSceneNum = 20;
_s22_caughtBefore = true; _s22_caughtBefore = true;
} }
while (!_sceneDone) { while (!_vm->_sceneDone) {
_vm->updateMouseCursor();
updateMouseCursor(); _vm->updateCursorByHotspot();
updateCursorByHotspot();
testWalk(0, 0, -1, -1, -1, -1); _vm->testWalk(0, 0, -1, -1, -1, -1);
_sceneClickedHotspot = getClickedHotspotId(); _vm->_sceneClickedHotspot = _vm->getClickedHotspotId();
updateGrabCursorSprite(0, 0); _vm->updateGrabCursorSprite(0, 0);
switch (_sceneClickedHotspot) { switch (_vm->_sceneClickedHotspot) {
case kHSDevice: case kHSDevice:
if (_gnapActionStatus < 0) { if (_vm->_gnapActionStatus < 0) {
runMenu(); _vm->runMenu();
scene22_updateHotspots(); updateHotspots();
} }
break; break;
case kHSPlatypus: case kHSPlatypus:
if (_gnapActionStatus < 0) { if (_vm->_gnapActionStatus < 0) {
if (_grabCursorSpriteIndex == kItemJoint) { if (_vm->_grabCursorSpriteIndex == kItemJoint) {
gnapUseJointOnPlatypus(); _vm->gnapUseJointOnPlatypus();
} else if (_grabCursorSpriteIndex >= 0) { } else if (_vm->_grabCursorSpriteIndex >= 0) {
playGnapImpossible(0, 0); _vm->playGnapImpossible(0, 0);
} else { } else {
switch (_verbCursor) { switch (_vm->_verbCursor) {
case LOOK_CURSOR: case LOOK_CURSOR:
playGnapScratchingHead(_platX, _platY); _vm->playGnapScratchingHead(_vm->_platX, _vm->_platY);
break; break;
case GRAB_CURSOR: case GRAB_CURSOR:
gnapKissPlatypus(0); _vm->gnapKissPlatypus(0);
break; break;
case TALK_CURSOR: case TALK_CURSOR:
playGnapBrainPulsating(_platX, _platY); _vm->playGnapBrainPulsating(_vm->_platX, _vm->_platY);
playPlatypusSequence(getPlatypusSequenceId()); _vm->playPlatypusSequence(_vm->getPlatypusSequenceId());
break; break;
case PLAT_CURSOR: case PLAT_CURSOR:
playGnapImpossible(0, 0); _vm->playGnapImpossible(0, 0);
break; break;
} }
} }
@ -161,45 +164,45 @@ void GnapEngine::scene22_run() {
break; break;
case kHSExitOutsideGrubCity: case kHSExitOutsideGrubCity:
if (_gnapActionStatus < 0) { if (_vm->_gnapActionStatus < 0) {
_isLeavingScene = true; _vm->_isLeavingScene = true;
_newSceneNum = 20; _vm->_newSceneNum = 20;
gnapWalkTo(_hotspotsWalkPos[kHSExitOutsideGrubCity].x, _hotspotsWalkPos[kHSExitOutsideGrubCity].y, 0, 0x107AF, 1); _vm->gnapWalkTo(_vm->_hotspotsWalkPos[kHSExitOutsideGrubCity].x, _vm->_hotspotsWalkPos[kHSExitOutsideGrubCity].y, 0, 0x107AF, 1);
_gnapActionStatus = kASLeaveScene; _vm->_gnapActionStatus = kASLeaveScene;
platypusWalkTo(_hotspotsWalkPos[kHSExitOutsideGrubCity].x, _hotspotsWalkPos[kHSExitOutsideGrubCity].y + 1, -1, 0x107C2, 1); _vm->platypusWalkTo(_vm->_hotspotsWalkPos[kHSExitOutsideGrubCity].x, _vm->_hotspotsWalkPos[kHSExitOutsideGrubCity].y + 1, -1, 0x107C2, 1);
} }
break; break;
case kHSExitBackGrubCity: case kHSExitBackGrubCity:
if (_gnapActionStatus < 0) { if (_vm->_gnapActionStatus < 0) {
_isLeavingScene = true; _vm->_isLeavingScene = true;
_newSceneNum = 23; _vm->_newSceneNum = 23;
gnapWalkTo(_hotspotsWalkPos[kHSExitBackGrubCity].x, _hotspotsWalkPos[kHSExitBackGrubCity].y, 0, 0x107AB, 1); _vm->gnapWalkTo(_vm->_hotspotsWalkPos[kHSExitBackGrubCity].x, _vm->_hotspotsWalkPos[kHSExitBackGrubCity].y, 0, 0x107AB, 1);
_gnapActionStatus = kASLeaveScene; _vm->_gnapActionStatus = kASLeaveScene;
platypusWalkTo(_hotspotsWalkPos[kHSExitBackGrubCity].x, _hotspotsWalkPos[kHSExitBackGrubCity].y + 1, -1, 0x107C2, 1); _vm->platypusWalkTo(_vm->_hotspotsWalkPos[kHSExitBackGrubCity].x, _vm->_hotspotsWalkPos[kHSExitBackGrubCity].y + 1, -1, 0x107C2, 1);
} }
break; break;
case kHSCashier: case kHSCashier:
if (_gnapActionStatus < 0) { if (_vm->_gnapActionStatus < 0) {
if (_grabCursorSpriteIndex >= 0) { if (_vm->_grabCursorSpriteIndex >= 0) {
playGnapShowCurrItem(_hotspotsWalkPos[kHSCashier].x, _hotspotsWalkPos[kHSCashier].y, 8, 4); _vm->playGnapShowCurrItem(_vm->_hotspotsWalkPos[kHSCashier].x, _vm->_hotspotsWalkPos[kHSCashier].y, 8, 4);
} else { } else {
switch (_verbCursor) { switch (_vm->_verbCursor) {
case LOOK_CURSOR: case LOOK_CURSOR:
playGnapScratchingHead(8, 4); _vm->playGnapScratchingHead(8, 4);
break; break;
case GRAB_CURSOR: case GRAB_CURSOR:
playGnapImpossible(0, 0); _vm->playGnapImpossible(0, 0);
break; break;
case TALK_CURSOR: case TALK_CURSOR:
_gnapIdleFacing = kDirUpRight; _vm->_gnapIdleFacing = kDirUpRight;
gnapWalkTo(_hotspotsWalkPos[kHSCashier].x, _hotspotsWalkPos[kHSCashier].y, _vm->gnapWalkTo(_vm->_hotspotsWalkPos[kHSCashier].x, _vm->_hotspotsWalkPos[kHSCashier].y,
0, getGnapSequenceId(gskBrainPulsating, 0, 0) | 0x10000, 1); 0, _vm->getGnapSequenceId(gskBrainPulsating, 0, 0) | 0x10000, 1);
_gnapActionStatus = kASTalkCashier; _vm->_gnapActionStatus = kASTalkCashier;
break; break;
case PLAT_CURSOR: case PLAT_CURSOR:
gnapUseDeviceOnPlatypuss(); _vm->gnapUseDeviceOnPlatypuss();
break; break;
} }
} }
@ -208,26 +211,25 @@ void GnapEngine::scene22_run() {
case kHSWalkArea1: case kHSWalkArea1:
case kHSWalkArea2: case kHSWalkArea2:
gnapWalkTo(-1, -1, -1, -1, 1); _vm->gnapWalkTo(-1, -1, -1, -1, 1);
break; break;
default: default:
if (_mouseClickState._left) { if (_vm->_mouseClickState._left) {
gnapWalkTo(-1, -1, -1, -1, 1); _vm->gnapWalkTo(-1, -1, -1, -1, 1);
_mouseClickState._left = false; _vm->_mouseClickState._left = false;
} }
break; break;
} }
scene22_updateAnimations(); updateAnimations();
if (!_isLeavingScene) { if (!_vm->_isLeavingScene) {
updatePlatypusIdleSequence(); _vm->updatePlatypusIdleSequence();
updateGnapIdleSequence(); _vm->updateGnapIdleSequence();
if (!_timers[6] && _s22_nextCashierSequenceId == -1) { if (!_vm->_timers[6] && _s22_nextCashierSequenceId == -1) {
_timers[6] = getRandom(30) + 20; _vm->_timers[6] = _vm->getRandom(30) + 20;
if (getRandom(8) != 0) { if (_vm->getRandom(8) != 0) {
_s22_nextCashierSequenceId = 0x59; _s22_nextCashierSequenceId = 0x59;
} else { } else {
_s22_cashierCtr = (_s22_cashierCtr + 1) % 3; _s22_cashierCtr = (_s22_cashierCtr + 1) % 3;
@ -249,46 +251,42 @@ void GnapEngine::scene22_run() {
} }
} }
checkGameKeys(); _vm->checkGameKeys();
if (isKeyStatus1(8)) { if (_vm->isKeyStatus1(8)) {
clearKeyStatus1(8); _vm->clearKeyStatus1(8);
runMenu(); _vm->runMenu();
scene22_updateHotspots(); updateHotspots();
_timers[2] = getRandom(30) + 20; _vm->_timers[2] = _vm->getRandom(30) + 20;
_timers[3] = 400; _vm->_timers[3] = 400;
_timers[1] = getRandom(20) + 30; _vm->_timers[1] = _vm->getRandom(20) + 30;
_timers[0] = getRandom(75) + 75; _vm->_timers[0] = _vm->getRandom(75) + 75;
} }
gameUpdateTick(); _vm->gameUpdateTick();
} }
} }
void GnapEngine::scene22_updateAnimations() { void Scene22::updateAnimations() {
if (_vm->_gameSys->getAnimationStatus(0) == 2) {
if (_gameSys->getAnimationStatus(0) == 2) { _vm->_gameSys->setAnimation(0, 0, 0);
_gameSys->setAnimation(0, 0, 0); switch (_vm->_gnapActionStatus) {
switch (_gnapActionStatus) {
case kASLeaveScene: case kASLeaveScene:
_sceneDone = true; _vm->_sceneDone = true;
break; break;
case kASTalkCashier: case kASTalkCashier:
_s22_nextCashierSequenceId = 0x5C; _s22_nextCashierSequenceId = 0x5C;
break; break;
} }
_gnapActionStatus = -1; _vm->_gnapActionStatus = -1;
} }
if (_gameSys->getAnimationStatus(3) == 2 && _s22_nextCashierSequenceId != -1) { if (_vm->_gameSys->getAnimationStatus(3) == 2 && _s22_nextCashierSequenceId != -1) {
_gameSys->setAnimation(_s22_nextCashierSequenceId, 1, 3); _vm->_gameSys->setAnimation(_s22_nextCashierSequenceId, 1, 3);
_gameSys->insertSequence(_s22_nextCashierSequenceId, 1, _s22_currCashierSequenceId, 1, kSeqSyncWait, 0, 0, 0); _vm->_gameSys->insertSequence(_s22_nextCashierSequenceId, 1, _s22_currCashierSequenceId, 1, kSeqSyncWait, 0, 0, 0);
_s22_currCashierSequenceId = _s22_nextCashierSequenceId; _s22_currCashierSequenceId = _s22_nextCashierSequenceId;
_s22_nextCashierSequenceId = -1; _s22_nextCashierSequenceId = -1;
} }
} }
} // End of namespace Gnap } // End of namespace Gnap

View File

@ -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

View File

@ -23,6 +23,7 @@
#include "gnap/gnap.h" #include "gnap/gnap.h"
#include "gnap/gamesys.h" #include "gnap/gamesys.h"
#include "gnap/resource.h" #include "gnap/resource.h"
#include "gnap/scenes/scene23.h"
namespace Gnap { namespace Gnap {
@ -42,90 +43,92 @@ enum {
kASLeaveScene = 3 kASLeaveScene = 3
}; };
int GnapEngine::scene23_init() { Scene23::Scene23(GnapEngine *vm) : Scene(vm) {
_s23_currStoreClerkSequenceId = -1;
_s23_nextStoreClerkSequenceId = -1;
}
int Scene23::init() {
return 0xC0; return 0xC0;
} }
void GnapEngine::scene23_updateHotspots() { void Scene23::updateHotspots() {
setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR); _vm->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); _vm->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); _vm->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); _vm->setHotspot(kHSWalkArea1, 0, 0, 340, 460);
setHotspot(kHSWalkArea2, 340, 0, 800, 501); _vm->setHotspot(kHSWalkArea2, 340, 0, 800, 501);
setDeviceHotspot(kHSDevice, -1, -1, -1, -1); _vm->setDeviceHotspot(kHSDevice, -1, -1, -1, -1);
_hotspotsCount = 6; _vm->_hotspotsCount = 6;
} }
void GnapEngine::scene23_run() { void Scene23::run() {
_vm->_timers[4] = _vm->getRandom(100) + 200;
_timers[4] = getRandom(100) + 200; _vm->_timers[5] = _vm->getRandom(100) + 200;
_timers[5] = getRandom(100) + 200;
_s23_currStoreClerkSequenceId = 0xB4; _s23_currStoreClerkSequenceId = 0xB4;
_s23_nextStoreClerkSequenceId = -1; _s23_nextStoreClerkSequenceId = -1;
_gameSys->setAnimation(0xB4, 1, 4); _vm->_gameSys->setAnimation(0xB4, 1, 4);
_gameSys->insertSequence(_s23_currStoreClerkSequenceId, 1, 0, 0, kSeqNone, 0, 0, 0); _vm->_gameSys->insertSequence(_s23_currStoreClerkSequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
queueInsertDeviceIcon(); _vm->queueInsertDeviceIcon();
initGnapPos(-1, 7, kDirBottomRight); _vm->initGnapPos(-1, 7, kDirBottomRight);
initPlatypusPos(-2, 7, kDirNone); _vm->initPlatypusPos(-2, 7, kDirNone);
_gameSys->insertSequence(0xBD, 255, 0, 0, kSeqNone, 0, 0, 0); _vm->_gameSys->insertSequence(0xBD, 255, 0, 0, kSeqNone, 0, 0, 0);
_gameSys->insertSequence(0xBF, 2, 0, 0, kSeqNone, 0, 0, 0); _vm->_gameSys->insertSequence(0xBF, 2, 0, 0, kSeqNone, 0, 0, 0);
endSceneInit(); _vm->endSceneInit();
platypusWalkTo(1, 7, -1, 0x107C2, 1); _vm->platypusWalkTo(1, 7, -1, 0x107C2, 1);
if (isFlag(kGFUnk24)) { if (_vm->isFlag(kGFUnk24)) {
gnapWalkTo(2, 7, -1, 0x107B9, 1); _vm->gnapWalkTo(2, 7, -1, 0x107B9, 1);
} else { } else {
gnapWalkTo(2, 7, 0, 0x107B9, 1); _vm->gnapWalkTo(2, 7, 0, 0x107B9, 1);
while (_gameSys->getAnimationStatus(0) != 2) while (_vm->_gameSys->getAnimationStatus(0) != 2)
gameUpdateTick(); _vm->gameUpdateTick();
playSequences(0x48, 0xBA, 0xBB, 0xBC); _vm->playSequences(0x48, 0xBA, 0xBB, 0xBC);
setFlag(kGFUnk24); _vm->setFlag(kGFUnk24);
} }
while (!_sceneDone) { while (!_vm->_sceneDone) {
_vm->updateMouseCursor();
_vm->updateCursorByHotspot();
updateMouseCursor(); _vm->testWalk(0, 3, -1, -1, -1, -1);
updateCursorByHotspot();
testWalk(0, 3, -1, -1, -1, -1); _vm->_sceneClickedHotspot = _vm->getClickedHotspotId();
_vm->updateGrabCursorSprite(0, 0);
_sceneClickedHotspot = getClickedHotspotId(); switch (_vm->_sceneClickedHotspot) {
updateGrabCursorSprite(0, 0);
switch (_sceneClickedHotspot) {
case kHSDevice: case kHSDevice:
if (_gnapActionStatus < 0) { if (_vm->_gnapActionStatus < 0) {
runMenu(); _vm->runMenu();
scene23_updateHotspots(); updateHotspots();
} }
break; break;
case kHSPlatypus: case kHSPlatypus:
if (_gnapActionStatus < 0) { if (_vm->_gnapActionStatus < 0) {
if (_grabCursorSpriteIndex == kItemJoint) { if (_vm->_grabCursorSpriteIndex == kItemJoint) {
gnapUseJointOnPlatypus(); _vm->gnapUseJointOnPlatypus();
} else if (_grabCursorSpriteIndex >= 0) { } else if (_vm->_grabCursorSpriteIndex >= 0) {
playGnapImpossible(0, 0); _vm->playGnapImpossible(0, 0);
} else { } else {
switch (_verbCursor) { switch (_vm->_verbCursor) {
case LOOK_CURSOR: case LOOK_CURSOR:
playGnapScratchingHead(_platX, _platY); _vm->playGnapScratchingHead(_vm->_platX, _vm->_platY);
break; break;
case GRAB_CURSOR: case GRAB_CURSOR:
gnapKissPlatypus(0); _vm->gnapKissPlatypus(0);
break; break;
case TALK_CURSOR: case TALK_CURSOR:
playGnapBrainPulsating(_platX, _platY); _vm->playGnapBrainPulsating(_vm->_platX, _vm->_platY);
playPlatypusSequence(getPlatypusSequenceId()); _vm->playPlatypusSequence(_vm->getPlatypusSequenceId());
break; break;
case PLAT_CURSOR: case PLAT_CURSOR:
playGnapImpossible(0, 0); _vm->playGnapImpossible(0, 0);
break; break;
} }
} }
@ -133,35 +136,35 @@ void GnapEngine::scene23_run() {
break; break;
case kHSCereals: case kHSCereals:
if (_gnapActionStatus < 0) { if (_vm->_gnapActionStatus < 0) {
if (_grabCursorSpriteIndex >= 0) { if (_vm->_grabCursorSpriteIndex >= 0) {
playGnapShowCurrItem(_hotspotsWalkPos[kHSCereals].x, _hotspotsWalkPos[kHSCereals].y, 5, 4); _vm->playGnapShowCurrItem(_vm->_hotspotsWalkPos[kHSCereals].x, _vm->_hotspotsWalkPos[kHSCereals].y, 5, 4);
} else { } else {
switch (_verbCursor) { switch (_vm->_verbCursor) {
case LOOK_CURSOR: case LOOK_CURSOR:
if (isFlag(kGFSceneFlag1)) if (_vm->isFlag(kGFSceneFlag1))
playGnapMoan2(0, 0); _vm->playGnapMoan2(0, 0);
else { else {
gnapWalkTo(_hotspotsWalkPos[kHSCereals].x, _hotspotsWalkPos[kHSCereals].y, _vm->gnapWalkTo(_vm->_hotspotsWalkPos[kHSCereals].x, _vm->_hotspotsWalkPos[kHSCereals].y,
0, getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1); 0, _vm->getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
_gnapActionStatus = kASLookCereals; _vm->_gnapActionStatus = kASLookCereals;
} }
break; break;
case GRAB_CURSOR: case GRAB_CURSOR:
if (isFlag(kGFSceneFlag1)) if (_vm->isFlag(kGFSceneFlag1))
playGnapImpossible(0, 0); _vm->playGnapImpossible(0, 0);
else { else {
_gnapIdleFacing = kDirBottomRight; _vm->_gnapIdleFacing = kDirBottomRight;
gnapWalkTo(_hotspotsWalkPos[kHSCereals].x, _hotspotsWalkPos[kHSCereals].y, _vm->gnapWalkTo(_vm->_hotspotsWalkPos[kHSCereals].x, _vm->_hotspotsWalkPos[kHSCereals].y,
0, getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1); 0, _vm->getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1);
setFlag(kGFSceneFlag1); _vm->setFlag(kGFSceneFlag1);
_gnapActionStatus = kASGrabCereals; _vm->_gnapActionStatus = kASGrabCereals;
invAdd(kItemCereals); _vm->invAdd(kItemCereals);
} }
break; break;
case TALK_CURSOR: case TALK_CURSOR:
case PLAT_CURSOR: case PLAT_CURSOR:
playGnapImpossible(0, 0); _vm->playGnapImpossible(0, 0);
break; break;
} }
} }
@ -169,109 +172,105 @@ void GnapEngine::scene23_run() {
break; break;
case kHSExitFrontGrubCity: case kHSExitFrontGrubCity:
if (_gnapActionStatus < 0) { if (_vm->_gnapActionStatus < 0) {
_isLeavingScene = true; _vm->_isLeavingScene = true;
_newSceneNum = 22; _vm->_newSceneNum = 22;
gnapWalkTo(_hotspotsWalkPos[kHSExitFrontGrubCity].x, _hotspotsWalkPos[kHSExitFrontGrubCity].y, 0, 0x107AF, 1); _vm->gnapWalkTo(_vm->_hotspotsWalkPos[kHSExitFrontGrubCity].x, _vm->_hotspotsWalkPos[kHSExitFrontGrubCity].y, 0, 0x107AF, 1);
_gnapActionStatus = kASLeaveScene; _vm->_gnapActionStatus = kASLeaveScene;
platypusWalkTo(_hotspotsWalkPos[kHSExitFrontGrubCity].x, _hotspotsWalkPos[kHSExitFrontGrubCity].y - 1, -1, 0x107C2, 1); _vm->platypusWalkTo(_vm->_hotspotsWalkPos[kHSExitFrontGrubCity].x, _vm->_hotspotsWalkPos[kHSExitFrontGrubCity].y - 1, -1, 0x107C2, 1);
} }
break; break;
case kHSWalkArea1: case kHSWalkArea1:
case kHSWalkArea2: case kHSWalkArea2:
if (_gnapActionStatus < 0) if (_vm->_gnapActionStatus < 0)
gnapWalkTo(-1, -1, -1, -1, 1); _vm->gnapWalkTo(-1, -1, -1, -1, 1);
break; break;
default: default:
if (_mouseClickState._left) { if (_vm->_mouseClickState._left) {
gnapWalkTo(-1, -1, -1, -1, 1); _vm->gnapWalkTo(-1, -1, -1, -1, 1);
_mouseClickState._left = false; _vm->_mouseClickState._left = false;
} }
break; break;
} }
scene23_updateAnimations(); updateAnimations();
if (!_isLeavingScene) { if (!_vm->_isLeavingScene) {
updatePlatypusIdleSequence(); _vm->updatePlatypusIdleSequence();
updateGnapIdleSequence(); _vm->updateGnapIdleSequence();
if (!_timers[4] && _gnapActionStatus == -1) { if (!_vm->_timers[4] && _vm->_gnapActionStatus == -1) {
_timers[4] = getRandom(100) + 200; _vm->_timers[4] = _vm->getRandom(100) + 200;
switch (getRandom(4)) { switch (_vm->getRandom(4)) {
case 0: case 0:
_gameSys->insertSequence(0xB7, 256, 0, 0, kSeqNone, 0, 0, 0); _vm->_gameSys->insertSequence(0xB7, 256, 0, 0, kSeqNone, 0, 0, 0);
break; break;
case 1: case 1:
_gameSys->insertSequence(0xB8, 256, 0, 0, kSeqNone, 0, 0, 0); _vm->_gameSys->insertSequence(0xB8, 256, 0, 0, kSeqNone, 0, 0, 0);
break; break;
case 2: case 2:
case 3: case 3:
_gameSys->insertSequence(0xB9, 256, 0, 0, kSeqNone, 0, 0, 0); _vm->_gameSys->insertSequence(0xB9, 256, 0, 0, kSeqNone, 0, 0, 0);
break; break;
} }
} }
if (!_timers[5]) { if (!_vm->_timers[5]) {
_timers[5] = getRandom(100) + 200; _vm->_timers[5] = _vm->getRandom(100) + 200;
switch (getRandom(3)) { switch (_vm->getRandom(3)) {
case 0: case 0:
playSound(0xCE, false); _vm->playSound(0xCE, false);
break; break;
case 1: case 1:
playSound(0xD0, false); _vm->playSound(0xD0, false);
break; break;
case 2: case 2:
playSound(0xCF, false); _vm->playSound(0xCF, false);
break; break;
} }
} }
} }
checkGameKeys(); _vm->checkGameKeys();
if (isKeyStatus1(8)) { if (_vm->isKeyStatus1(8)) {
clearKeyStatus1(8); _vm->clearKeyStatus1(8);
runMenu(); _vm->runMenu();
scene23_updateHotspots(); updateHotspots();
} }
gameUpdateTick(); _vm->gameUpdateTick();
} }
} }
void GnapEngine::scene23_updateAnimations() { void Scene23::updateAnimations() {
if (_vm->_gameSys->getAnimationStatus(0) == 2) {
if (_gameSys->getAnimationStatus(0) == 2) { _vm->_gameSys->setAnimation(0, 0, 0);
_gameSys->setAnimation(0, 0, 0); switch (_vm->_gnapActionStatus) {
switch (_gnapActionStatus) {
case kASLookCereals: case kASLookCereals:
showFullScreenSprite(0x48); _vm->showFullScreenSprite(0x48);
_gnapActionStatus = -1; _vm->_gnapActionStatus = -1;
break; break;
case kASGrabCereals: case kASGrabCereals:
_gameSys->setAnimation(0xBE, _gnapId, 0); _vm->_gameSys->setAnimation(0xBE, _vm->_gnapId, 0);
_gameSys->insertSequence(0xBE, _gnapId, makeRid(_gnapSequenceDatNum, _gnapSequenceId), _gnapId, kSeqSyncWait, 0, 0, 0); _vm->_gameSys->insertSequence(0xBE, _vm->_gnapId, makeRid(_vm->_gnapSequenceDatNum, _vm->_gnapSequenceId), _vm->_gnapId, kSeqSyncWait, 0, 0, 0);
_gameSys->requestRemoveSequence(0xBF, 2); _vm->_gameSys->requestRemoveSequence(0xBF, 2);
_gnapSequenceDatNum = 0; _vm->_gnapSequenceDatNum = 0;
_gnapSequenceId = 0xBE; _vm->_gnapSequenceId = 0xBE;
_gnapActionStatus = kASGrabCerealsDone; _vm->_gnapActionStatus = kASGrabCerealsDone;
break; break;
case kASGrabCerealsDone: case kASGrabCerealsDone:
setGrabCursorSprite(kItemCereals); _vm->setGrabCursorSprite(kItemCereals);
_gnapActionStatus = -1; _vm->_gnapActionStatus = -1;
break; break;
case kASLeaveScene: case kASLeaveScene:
_sceneDone = true; _vm->_sceneDone = true;
break; break;
} }
} }
if (_gameSys->getAnimationStatus(4) == 2 && _s23_nextStoreClerkSequenceId == -1) { if (_vm->_gameSys->getAnimationStatus(4) == 2 && _s23_nextStoreClerkSequenceId == -1) {
switch (getRandom(8)) { switch (_vm->getRandom(8)) {
case 0: case 0:
case 1: case 1:
case 2: case 2:
@ -286,12 +285,11 @@ void GnapEngine::scene23_updateAnimations() {
_s23_nextStoreClerkSequenceId = 0xB6; _s23_nextStoreClerkSequenceId = 0xB6;
break; break;
} }
_gameSys->setAnimation(_s23_nextStoreClerkSequenceId, 1, 4); _vm->_gameSys->setAnimation(_s23_nextStoreClerkSequenceId, 1, 4);
_gameSys->insertSequence(_s23_nextStoreClerkSequenceId, 1, _s23_currStoreClerkSequenceId, 1, kSeqSyncWait, 0, 0, 0); _vm->_gameSys->insertSequence(_s23_nextStoreClerkSequenceId, 1, _s23_currStoreClerkSequenceId, 1, kSeqSyncWait, 0, 0, 0);
_s23_currStoreClerkSequenceId = _s23_nextStoreClerkSequenceId; _s23_currStoreClerkSequenceId = _s23_nextStoreClerkSequenceId;
_s23_nextStoreClerkSequenceId = -1; _s23_nextStoreClerkSequenceId = -1;
} }
} }
} // End of namespace Gnap } // End of namespace Gnap

View File

@ -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

View File

@ -47,6 +47,8 @@
#include "gnap/scenes/scene19.h" #include "gnap/scenes/scene19.h"
#include "gnap/scenes/scene20.h" #include "gnap/scenes/scene20.h"
#include "gnap/scenes/scene21.h" #include "gnap/scenes/scene21.h"
#include "gnap/scenes/scene22.h"
#include "gnap/scenes/scene23.h"
#include "gnap/scenes/scene47.h" #include "gnap/scenes/scene47.h"
#include "gnap/scenes/scene48.h" #include "gnap/scenes/scene48.h"
#include "gnap/scenes/scene54.h" #include "gnap/scenes/scene54.h"
@ -208,14 +210,16 @@ int GnapEngine::initSceneLogic() {
initSceneGrid(21, 146, 11, 10); initSceneGrid(21, 146, 11, 10);
break; break;
case 22: case 22:
backgroundId = scene22_init(); _scene = new Scene22(this);
scene22_updateHotspots(); backgroundId = _scene->init();
_scene->updateHotspots();
_gameSys->setScaleValues(0, 500, 1, 1000); _gameSys->setScaleValues(0, 500, 1, 1000);
initSceneGrid(21, 146, 11, 10); initSceneGrid(21, 146, 11, 10);
break; break;
case 23: case 23:
backgroundId = scene23_init(); _scene = new Scene23(this);
scene23_updateHotspots(); backgroundId = _scene->init();
_scene->updateHotspots();
_gameSys->setScaleValues(0, 500, 1, 1000); _gameSys->setScaleValues(0, 500, 1, 1000);
initSceneGrid(21, 146, 11, 10); initSceneGrid(21, 146, 11, 10);
break; break;
@ -530,12 +534,14 @@ void GnapEngine::runSceneLogic() {
_newSceneNum = 20; _newSceneNum = 20;
break; break;
case 22: case 22:
scene22_run(); _scene->run();
delete _scene;
if (_newSceneNum == 55) if (_newSceneNum == 55)
_newSceneNum = 20; _newSceneNum = 20;
break; break;
case 23: case 23:
scene23_run(); _scene->run();
delete _scene;
if (_newSceneNum == 55) if (_newSceneNum == 55)
_newSceneNum = 20; _newSceneNum = 20;
break; break;