diff options
author | Strangerke | 2016-04-19 07:57:07 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-05-10 09:54:21 +0200 |
commit | 145b3751199219c4707e8f3462e2c63916b46460 (patch) | |
tree | 8536322f911af903cdf38162599dbd090da955c3 /engines/gnap | |
parent | 70fec4db2cbc89893c45beb27c54dc87699a7265 (diff) | |
download | scummvm-rg350-145b3751199219c4707e8f3462e2c63916b46460.tar.gz scummvm-rg350-145b3751199219c4707e8f3462e2c63916b46460.tar.bz2 scummvm-rg350-145b3751199219c4707e8f3462e2c63916b46460.zip |
GNAP: Refactor Scene01 (WIP)
Diffstat (limited to 'engines/gnap')
-rw-r--r-- | engines/gnap/gnap.cpp | 7 | ||||
-rw-r--r-- | engines/gnap/gnap.h | 14 | ||||
-rw-r--r-- | engines/gnap/scenes/scene01.cpp | 357 | ||||
-rw-r--r-- | engines/gnap/scenes/scene01.h | 49 | ||||
-rw-r--r-- | engines/gnap/scenes/scenecore.cpp | 11 | ||||
-rw-r--r-- | engines/gnap/scenes/scenecore.h | 48 |
6 files changed, 292 insertions, 194 deletions
diff --git a/engines/gnap/gnap.cpp b/engines/gnap/gnap.cpp index 15c949ab77..dbe081c636 100644 --- a/engines/gnap/gnap.cpp +++ b/engines/gnap/gnap.cpp @@ -98,6 +98,7 @@ GnapEngine::GnapEngine(OSystem *syst, const ADGameDescription *gd) : DebugMan.addDebugChannel(kDebugBasic, "basic", "Basic debug level"); Engine::syncSoundSettings(); + _scene = nullptr; } GnapEngine::~GnapEngine() { @@ -2021,12 +2022,6 @@ void GnapEngine::initPlatypusPos(int gridX, int gridY, Facing facing) { //////////////////////////////////////////////////////////////////////////////// void GnapEngine::initGlobalSceneVars() { - - // Scene 1 - _s01_pigsIdCtr = 0; - _s01_smokeIdCtr = 0; - _s01_spaceshipSurface = 0; - // Scene 2 _s02_truckGrillCtr = 0; diff --git a/engines/gnap/gnap.h b/engines/gnap/gnap.h index 3517838951..a56df314b0 100644 --- a/engines/gnap/gnap.h +++ b/engines/gnap/gnap.h @@ -41,6 +41,7 @@ #include "gnap/debugger.h" #include "gnap/resource.h" +#include "gnap/scenes/scenecore.h" struct ADGameDescription; @@ -312,7 +313,8 @@ public: GameSys *_gameSys; SoundMan *_soundMan; Debugger *_debugger; - + Scene *_scene; + int _lastUpdateClock; int _debugLevel; @@ -604,15 +606,7 @@ public: // Scene 0 int scene00_init(); void scene00_run(); - - // Scene 1 - int _s01_pigsIdCtr, _s01_smokeIdCtr; - Graphics::Surface *_s01_spaceshipSurface; - int scene01_init(); - void scene01_updateHotspots(); - void scene01_run(); - void scene01_updateAnimations(); - + // Scene 2 int _s02_truckGrillCtr; int _s02_nextChickenSequenceId, _s02_currChickenSequenceId; diff --git a/engines/gnap/scenes/scene01.cpp b/engines/gnap/scenes/scene01.cpp index 808c190af1..be104a2649 100644 --- a/engines/gnap/scenes/scene01.cpp +++ b/engines/gnap/scenes/scene01.cpp @@ -23,6 +23,7 @@ #include "gnap/gnap.h" #include "gnap/gamesys.h" #include "gnap/resource.h" +#include "gnap/scenes/scene01.h" namespace Gnap { @@ -52,110 +53,115 @@ enum { kASUsePigs = 7 }; -int GnapEngine::scene01_init() { - _gameSys->setAnimation(0, 0, 0); - _gameSys->setAnimation(0, 0, 3); +Scene01::Scene01(GnapEngine *vm) : Scene(vm) { + _s01_pigsIdCtr = 0; + _s01_smokeIdCtr = 0; + _s01_spaceshipSurface = nullptr; +} + +int Scene01::init() { + _vm->_gameSys->setAnimation(0, 0, 0); + _vm->_gameSys->setAnimation(0, 0, 3); return 0x88; } -void GnapEngine::scene01_updateHotspots() { - setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_DISABLED | SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR); - setHotspot(kHSExitTruck, 780, 226, 800, 455, SF_EXIT_R_CURSOR | SF_WALKABLE, 10, 6); - setHotspot(kHSMud, 138, 282, 204, 318, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 3, 5); - setHotspot(kHSPigs, 408, 234, 578, 326, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 6, 4); - setHotspot(kHSSpaceship, 0, 200, 94, 292, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 1, 6); - setHotspot(kHSWalkArea1, 0, 0, 162, 426); - setHotspot(kHSWalkArea2, 162, 0, 237, 396); - setHotspot(kHSWalkArea3, 237, 0, 319, 363); - setHotspot(kHSWalkArea4, 520, 0, 800, 404); - setHotspot(kHSWalkArea5, 300, 447, 800, 600); - setHotspot(kHSWalkArea6, 678, 0, 800, 404); - setHotspot(kHSWalkArea7, 0, 0, 520, 351); - setHotspot(kHSWalkArea8, 0, 546, 300, 600); - 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(kGFMudTaken)) - _hotspots[kHSMud]._flags = SF_WALKABLE | SF_DISABLED; - _hotspotsCount = 14; +void Scene01::updateHotspots() { + _vm->setHotspot(kHSPlatypus, 0, 0, 0, 0, SF_DISABLED | SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR); + _vm->setHotspot(kHSExitTruck, 780, 226, 800, 455, SF_EXIT_R_CURSOR | SF_WALKABLE, 10, 6); + _vm->setHotspot(kHSMud, 138, 282, 204, 318, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 3, 5); + _vm->setHotspot(kHSPigs, 408, 234, 578, 326, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 6, 4); + _vm->setHotspot(kHSSpaceship, 0, 200, 94, 292, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 1, 6); + _vm->setHotspot(kHSWalkArea1, 0, 0, 162, 426); + _vm->setHotspot(kHSWalkArea2, 162, 0, 237, 396); + _vm->setHotspot(kHSWalkArea3, 237, 0, 319, 363); + _vm->setHotspot(kHSWalkArea4, 520, 0, 800, 404); + _vm->setHotspot(kHSWalkArea5, 300, 447, 800, 600); + _vm->setHotspot(kHSWalkArea6, 678, 0, 800, 404); + _vm->setHotspot(kHSWalkArea7, 0, 0, 520, 351); + _vm->setHotspot(kHSWalkArea8, 0, 546, 300, 600); + _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(kGFMudTaken)) + _vm->_hotspots[kHSMud]._flags = SF_WALKABLE | SF_DISABLED; + _vm->_hotspotsCount = 14; } -void GnapEngine::scene01_run() { +void Scene01::run() { // NOTE Removed _s01_dword_474380 which was set when the mud was taken // which is also set in the global game flags. - playSound(0x1091C, true); - startSoundTimerC(5); + _vm->playSound(0x1091C, true); + _vm->startSoundTimerC(5); - _gameSys->setAnimation(134, 20, 4); - _gameSys->insertSequence(134, 20, 0, 0, kSeqNone, 0, 0, 0); + _vm->_gameSys->setAnimation(134, 20, 4); + _vm->_gameSys->insertSequence(134, 20, 0, 0, kSeqNone, 0, 0, 0); - _gameSys->setAnimation(0x7F, 40, 2); - _gameSys->insertSequence(0x7F, 40, 0, 0, kSeqNone, 0, 0, 0); + _vm->_gameSys->setAnimation(0x7F, 40, 2); + _vm->_gameSys->insertSequence(0x7F, 40, 0, 0, kSeqNone, 0, 0, 0); - _timers[4] = getRandom(100) + 300; + _vm->_timers[4] = _vm->getRandom(100) + 300; - if (!isFlag(kGFMudTaken)) - _gameSys->insertSequence(129, 40, 0, 0, kSeqNone, 0, 0, 0); + if (!_vm->isFlag(kGFMudTaken)) + _vm->_gameSys->insertSequence(129, 40, 0, 0, kSeqNone, 0, 0, 0); - queueInsertDeviceIcon(); + _vm->queueInsertDeviceIcon(); - if (_prevSceneNum == 2) { - initGnapPos(11, 6, kDirBottomLeft); - if (isFlag(kGFPlatypus)) - initPlatypusPos(12, 6, kDirUnk4); - endSceneInit(); - if (isFlag(kGFPlatypus)) - platypusWalkTo(9, 6, -1, 0x107C2, 1); - gnapWalkTo(8, 6, -1, 0x107B9, 1); + if (_vm->_prevSceneNum == 2) { + _vm->initGnapPos(11, 6, kDirBottomLeft); + if (_vm->isFlag(kGFPlatypus)) + _vm->initPlatypusPos(12, 6, kDirUnk4); + _vm->endSceneInit(); + if (_vm->isFlag(kGFPlatypus)) + _vm->platypusWalkTo(9, 6, -1, 0x107C2, 1); + _vm->gnapWalkTo(8, 6, -1, 0x107B9, 1); } else { - initGnapPos(1, 6, kDirBottomRight); - if (isFlag(kGFPlatypus)) - initPlatypusPos(1, 7, kDirNone); - endSceneInit(); + _vm->initGnapPos(1, 6, kDirBottomRight); + if (_vm->isFlag(kGFPlatypus)) + _vm->initPlatypusPos(1, 7, kDirNone); + _vm->endSceneInit(); } - while (!_sceneDone) { - - updateMouseCursor(); - updateCursorByHotspot(); - testWalk(0, 3, -1, -1, -1, -1); + while (!_vm->_sceneDone) { + _vm->updateMouseCursor(); + _vm->updateCursorByHotspot(); + _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(); - scene01_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; } } @@ -163,20 +169,20 @@ void GnapEngine::scene01_run() { break; case kHSSpaceship: - if (_gnapActionStatus < 0) { - if (_grabCursorSpriteIndex >= 0) { - playGnapShowCurrItem(_hotspotsWalkPos[4].x, _hotspotsWalkPos[4].y, 0, 2); + if (_vm->_gnapActionStatus < 0) { + if (_vm->_grabCursorSpriteIndex >= 0) { + _vm->playGnapShowCurrItem(_vm->_hotspotsWalkPos[4].x, _vm->_hotspotsWalkPos[4].y, 0, 2); } else { - switch (_verbCursor) { + switch (_vm->_verbCursor) { case LOOK_CURSOR: - _gnapIdleFacing = kDirUpLeft; - if (gnapWalkTo(_hotspotsWalkPos[4].x, _hotspotsWalkPos[4].y, 0, getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1)) - _gnapActionStatus = kASLookSpaceship; + _vm->_gnapIdleFacing = kDirUpLeft; + if (_vm->gnapWalkTo(_vm->_hotspotsWalkPos[4].x, _vm->_hotspotsWalkPos[4].y, 0, _vm->getGnapSequenceId(gskIdle, 0, 0) | 0x10000, 1)) + _vm->_gnapActionStatus = kASLookSpaceship; break; case GRAB_CURSOR: case TALK_CURSOR: case PLAT_CURSOR: - playGnapImpossible(0, 0); + _vm->playGnapImpossible(0, 0); break; } } @@ -184,21 +190,21 @@ void GnapEngine::scene01_run() { break; case kHSMud: - if (_gnapActionStatus < 0) { - if (_grabCursorSpriteIndex >= 0) { - playGnapShowCurrItem(_hotspotsWalkPos[2].x, _hotspotsWalkPos[2].y, 2, 3); + if (_vm->_gnapActionStatus < 0) { + if (_vm->_grabCursorSpriteIndex >= 0) { + _vm->playGnapShowCurrItem(_vm->_hotspotsWalkPos[2].x, _vm->_hotspotsWalkPos[2].y, 2, 3); } else { - switch (_verbCursor) { + switch (_vm->_verbCursor) { case LOOK_CURSOR: - playGnapScratchingHead(3, 3); + _vm->playGnapScratchingHead(3, 3); break; case GRAB_CURSOR: - gnapWalkTo(_hotspotsWalkPos[2].x, _hotspotsWalkPos[2].y, 0, getGnapSequenceId(gskIdle, 2, 3) | 0x10000, 1); - _gnapActionStatus = kASTakeMud; + _vm->gnapWalkTo(_vm->_hotspotsWalkPos[2].x, _vm->_hotspotsWalkPos[2].y, 0, _vm->getGnapSequenceId(gskIdle, 2, 3) | 0x10000, 1); + _vm->_gnapActionStatus = kASTakeMud; break; case TALK_CURSOR: case PLAT_CURSOR: - playGnapImpossible(0, 0); + _vm->playGnapImpossible(0, 0); break; } } @@ -206,28 +212,28 @@ void GnapEngine::scene01_run() { break; case kHSPigs: - if (_gnapActionStatus < 0) { - if (_grabCursorSpriteIndex >= 0) { - playGnapShowCurrItem(_hotspotsWalkPos[3].x, _hotspotsWalkPos[3].y, 7, 2); + if (_vm->_gnapActionStatus < 0) { + if (_vm->_grabCursorSpriteIndex >= 0) { + _vm->playGnapShowCurrItem(_vm->_hotspotsWalkPos[3].x, _vm->_hotspotsWalkPos[3].y, 7, 2); } else { - switch (_verbCursor) { + switch (_vm->_verbCursor) { case LOOK_CURSOR: - _gnapIdleFacing = kDirUpRight; - gnapWalkTo(_hotspotsWalkPos[3].x, _hotspotsWalkPos[3].y, 0, getGnapSequenceId(gskIdle, 7, 2) | 0x10000, 1); - _gnapActionStatus = kASLookPigs; + _vm->_gnapIdleFacing = kDirUpRight; + _vm->gnapWalkTo(_vm->_hotspotsWalkPos[3].x, _vm->_hotspotsWalkPos[3].y, 0, _vm->getGnapSequenceId(gskIdle, 7, 2) | 0x10000, 1); + _vm->_gnapActionStatus = kASLookPigs; break; case GRAB_CURSOR: - _gnapIdleFacing = kDirUpRight; - gnapWalkTo(_hotspotsWalkPos[3].x, _hotspotsWalkPos[3].y, 0, getGnapSequenceId(gskIdle, 7, 2) | 0x10000, 1); - _gnapActionStatus = kASUsePigs; + _vm->_gnapIdleFacing = kDirUpRight; + _vm->gnapWalkTo(_vm->_hotspotsWalkPos[3].x, _vm->_hotspotsWalkPos[3].y, 0, _vm->getGnapSequenceId(gskIdle, 7, 2) | 0x10000, 1); + _vm->_gnapActionStatus = kASUsePigs; break; case TALK_CURSOR: - _gnapIdleFacing = kDirUpRight; - gnapWalkTo(_hotspotsWalkPos[3].x, _hotspotsWalkPos[3].y, 0, getGnapSequenceId(gskBrainPulsating, 7, 2) | 0x10000, 1); - _gnapActionStatus = kASLookPigs; + _vm->_gnapIdleFacing = kDirUpRight; + _vm->gnapWalkTo(_vm->_hotspotsWalkPos[3].x, _vm->_hotspotsWalkPos[3].y, 0, _vm->getGnapSequenceId(gskBrainPulsating, 7, 2) | 0x10000, 1); + _vm->_gnapActionStatus = kASLookPigs; break; case PLAT_CURSOR: - playGnapImpossible(0, 0); + _vm->playGnapImpossible(0, 0); break; } } @@ -235,13 +241,13 @@ void GnapEngine::scene01_run() { break; case kHSExitTruck: - if (_gnapActionStatus < 0) { - _isLeavingScene = true; - gnapWalkTo(_hotspotsWalkPos[1].x, _hotspotsWalkPos[1].y, 0, 0x107AB, 1); - _gnapActionStatus = kASLeaveScene; - if (isFlag(kGFPlatypus)) - platypusWalkTo(_hotspotsWalkPos[1].x, _hotspotsWalkPos[1].y + 1, -1, 0x107CD, 1); - _newSceneNum = 2; + if (_vm->_gnapActionStatus < 0) { + _vm->_isLeavingScene = true; + _vm->gnapWalkTo(_vm->_hotspotsWalkPos[1].x, _vm->_hotspotsWalkPos[1].y, 0, 0x107AB, 1); + _vm->_gnapActionStatus = kASLeaveScene; + if (_vm->isFlag(kGFPlatypus)) + _vm->platypusWalkTo(_vm->_hotspotsWalkPos[1].x, _vm->_hotspotsWalkPos[1].y + 1, -1, 0x107CD, 1); + _vm->_newSceneNum = 2; } break; @@ -253,120 +259,121 @@ void GnapEngine::scene01_run() { case kHSWalkArea6: case kHSWalkArea7: case kHSWalkArea8: - 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 && _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; } - scene01_updateAnimations(); + updateAnimations(); - if (!isSoundPlaying(0x1091C)) - playSound(0x1091C, true); + if (!_vm->isSoundPlaying(0x1091C)) + _vm->playSound(0x1091C, true); - if (!_isLeavingScene) { - if (_platypusActionStatus < 0 && isFlag(kGFPlatypus)) - updatePlatypusIdleSequence(); - if (_gnapActionStatus < 0) - updateGnapIdleSequence(); - if (_timers[4] == 0) { + if (!_vm->_isLeavingScene) { + if (_vm->_platypusActionStatus < 0 && _vm->isFlag(kGFPlatypus)) + _vm->updatePlatypusIdleSequence(); + if (_vm->_gnapActionStatus < 0) + _vm->updateGnapIdleSequence(); + if (_vm->_timers[4] == 0) { // Update bird animation - _timers[4] = getRandom(100) + 300; - if (getRandom(1) == 0) - _gameSys->insertSequence(0x84, 180, 0, 0, kSeqNone, 0, 0, 0); + _vm->_timers[4] = _vm->getRandom(100) + 300; + if (_vm->getRandom(1) == 0) + _vm->_gameSys->insertSequence(0x84, 180, 0, 0, kSeqNone, 0, 0, 0); else - _gameSys->insertSequence(0x83, 180, 0, 0, kSeqNone, 0, 0, 0); + _vm->_gameSys->insertSequence(0x83, 180, 0, 0, kSeqNone, 0, 0, 0); } - playSoundC(); + _vm->playSoundC(); } - checkGameKeys(); - if (isKeyStatus1(8)) { - clearKeyStatus1(8); - runMenu(); - scene01_updateHotspots(); + _vm->checkGameKeys(); + if (_vm->isKeyStatus1(8)) { + _vm->clearKeyStatus1(8); + _vm->runMenu(); + updateHotspots(); } - gameUpdateTick(); - + _vm->gameUpdateTick(); } - } -void GnapEngine::scene01_updateAnimations() { - - if (_gameSys->getAnimationStatus(0) == 2) { - _gameSys->setAnimation(0, 0, 0); - switch (_gnapActionStatus) { +void Scene01::updateAnimations() { + if (_vm->_gameSys->getAnimationStatus(0) == 2) { + _vm->_gameSys->setAnimation(0, 0, 0); + switch (_vm->_gnapActionStatus) { case kASLookSpaceship: - _s01_spaceshipSurface = _gameSys->createSurface(47); - _gameSys->insertSpriteDrawItem(_s01_spaceshipSurface, 0, 0, 255); - _gameSys->setAnimation(133, 256, 0); - _gameSys->insertSequence(133, 256, 0, 0, kSeqNone, 0, 0, 0); - _gnapActionStatus = kASLookSpaceshipDone; + _s01_spaceshipSurface = _vm->_gameSys->createSurface(47); + _vm->_gameSys->insertSpriteDrawItem(_s01_spaceshipSurface, 0, 0, 255); + _vm->_gameSys->setAnimation(133, 256, 0); + _vm->_gameSys->insertSequence(133, 256, 0, 0, kSeqNone, 0, 0, 0); + _vm->_gnapActionStatus = kASLookSpaceshipDone; break; + case kASLookSpaceshipDone: - _gameSys->removeSequence(133, 256, true); - _gameSys->removeSpriteDrawItem(_s01_spaceshipSurface, 255); - deleteSurface(&_s01_spaceshipSurface); - _gnapActionStatus = -1; + _vm->_gameSys->removeSequence(133, 256, true); + _vm->_gameSys->removeSpriteDrawItem(_s01_spaceshipSurface, 255); + _vm->deleteSurface(&_s01_spaceshipSurface); + _vm->_gnapActionStatus = -1; break; + case kASLeaveScene: - _sceneDone = true; + _vm->_sceneDone = true; break; + case kASTakeMud: - playGnapPullOutDevice(2, 3); - playGnapUseDevice(0, 0); - _gameSys->insertSequence(128, 40, 129, 40, kSeqSyncWait, 0, 0, 0); - _gameSys->setAnimation(128, 40, 3); - _gnapActionStatus = -1; + _vm->playGnapPullOutDevice(2, 3); + _vm->playGnapUseDevice(0, 0); + _vm->_gameSys->insertSequence(128, 40, 129, 40, kSeqSyncWait, 0, 0, 0); + _vm->_gameSys->setAnimation(128, 40, 3); + _vm->_gnapActionStatus = -1; break; + case kASLookPigs: - playSound(138, false); - playSound(139, false); - playSound(140, false); - _gnapActionStatus = -1; + _vm->playSound(138, false); + _vm->playSound(139, false); + _vm->playSound(140, false); + _vm->_gnapActionStatus = -1; break; + case kASUsePigs: - playGnapPullOutDevice(7, 2); - playGnapUseDevice(0, 0); - _gameSys->insertSequence(135, 39, 0, 0, kSeqNone, 25, getRandom(140) - 40, 0); - _gnapActionStatus = -1; + _vm->playGnapPullOutDevice(7, 2); + _vm->playGnapUseDevice(0, 0); + _vm->_gameSys->insertSequence(135, 39, 0, 0, kSeqNone, 25, _vm->getRandom(140) - 40, 0); + _vm->_gnapActionStatus = -1; break; } } - if (_gameSys->getAnimationStatus(3) == 2) { - _gameSys->setAnimation(0, 0, 3); - invAdd(kItemMud); - setGrabCursorSprite(kItemMud); - setFlag(kGFMudTaken); - scene01_updateHotspots(); + if (_vm->_gameSys->getAnimationStatus(3) == 2) { + _vm->_gameSys->setAnimation(0, 0, 3); + _vm->invAdd(kItemMud); + _vm->setGrabCursorSprite(kItemMud); + _vm->setFlag(kGFMudTaken); + updateHotspots(); } - if (_gameSys->getAnimationStatus(4) == 2) { + if (_vm->_gameSys->getAnimationStatus(4) == 2) { _s01_smokeIdCtr = (_s01_smokeIdCtr + 1) % 2; - _gameSys->setAnimation(0x86, _s01_smokeIdCtr + 20, 4); - _gameSys->insertSequence(0x86, _s01_smokeIdCtr + 20, + _vm->_gameSys->setAnimation(0x86, _s01_smokeIdCtr + 20, 4); + _vm->_gameSys->insertSequence(0x86, _s01_smokeIdCtr + 20, 0x86, (_s01_smokeIdCtr + 1) % 2 + 20, kSeqSyncWait, 0, 0, 0); } - if (_gameSys->getAnimationStatus(2) == 2) { + if (_vm->_gameSys->getAnimationStatus(2) == 2) { _s01_pigsIdCtr = (_s01_pigsIdCtr + 1) % 2; - _gameSys->setAnimation(0x7F, _s01_pigsIdCtr + 40, 2); - _gameSys->insertSequence(0x7F, _s01_pigsIdCtr + 40, + _vm->_gameSys->setAnimation(0x7F, _s01_pigsIdCtr + 40, 2); + _vm->_gameSys->insertSequence(0x7F, _s01_pigsIdCtr + 40, 0x7F, (_s01_pigsIdCtr + 1) % 2 + 40, kSeqSyncWait, 0, 0, 0); } - } } // End of namespace Gnap diff --git a/engines/gnap/scenes/scene01.h b/engines/gnap/scenes/scene01.h new file mode 100644 index 0000000000..b24ae53132 --- /dev/null +++ b/engines/gnap/scenes/scene01.h @@ -0,0 +1,49 @@ +/* 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_SCENE01_H +#define GNAP_SCENE01_H + +#include "gnap/debugger.h" +#include "gnap/scenes/scenecore.h" + +namespace Gnap { + +class GnapEngine; + +class Scene01: public Scene { +public: + Scene01(GnapEngine *vm); + + virtual int init(); + virtual void updateHotspots(); + virtual void run(); + virtual void updateAnimations(); + +private: + int _s01_pigsIdCtr, _s01_smokeIdCtr; + Graphics::Surface *_s01_spaceshipSurface; +}; + +} // End of namespace Gnap + +#endif // GNAP_SCENE01_H diff --git a/engines/gnap/scenes/scenecore.cpp b/engines/gnap/scenes/scenecore.cpp index ba1ea40d21..104eea06e0 100644 --- a/engines/gnap/scenes/scenecore.cpp +++ b/engines/gnap/scenes/scenecore.cpp @@ -23,6 +23,9 @@ #include "gnap/gnap.h" #include "gnap/gamesys.h" #include "gnap/resource.h" +#include "gnap/scenes/scenecore.h" + +#include "gnap/scenes/scene01.h" namespace Gnap { @@ -36,8 +39,9 @@ int GnapEngine::initSceneLogic() { _gameSys->setScaleValues(0, 500, 1, 1000); break; case 1: - backgroundId = scene01_init(); - scene01_updateHotspots(); + _scene = new Scene01(this); + backgroundId = _scene->init(); + _scene->updateHotspots(); _gameSys->setScaleValues(0, 500, 1, 1000); initSceneGrid(21, 146, 11, 10); break; @@ -350,7 +354,8 @@ void GnapEngine::runSceneLogic() { _newSceneNum = 8; break; case 1: - scene01_run(); + _scene->run(); + delete _scene; if (_newSceneNum == 55) _newSceneNum = 4; break; diff --git a/engines/gnap/scenes/scenecore.h b/engines/gnap/scenes/scenecore.h new file mode 100644 index 0000000000..a97bf5c8e4 --- /dev/null +++ b/engines/gnap/scenes/scenecore.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_SCENECORE_H +#define GNAP_SCENECORE_H + +#include "gnap/debugger.h" + +namespace Gnap { + +class GnapEngine; + +class Scene { +public: + Scene(GnapEngine *vm) : _vm(vm) {}; + ~Scene() {}; + + virtual int init() = 0; + virtual void updateHotspots() = 0; + virtual void run() = 0; + virtual void updateAnimations() = 0; + +protected: + GnapEngine *_vm; +}; + +} // End of namespace Gnap + +#endif // GNAP_SCENECORE_H |