diff options
author | Strangerke | 2016-04-24 22:38:30 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-05-10 09:54:21 +0200 |
commit | 7a66d4b3568ebcfae549f13e87549f2771f36732 (patch) | |
tree | 0fc132bdf1133b627cdfcea81908d093433ffc86 /engines/gnap | |
parent | aca5984e2b2f08890f828bbe9c331841c9b33674 (diff) | |
download | scummvm-rg350-7a66d4b3568ebcfae549f13e87549f2771f36732.tar.gz scummvm-rg350-7a66d4b3568ebcfae549f13e87549f2771f36732.tar.bz2 scummvm-rg350-7a66d4b3568ebcfae549f13e87549f2771f36732.zip |
GNAP: Refactor scenes 51&52
Diffstat (limited to 'engines/gnap')
-rw-r--r-- | engines/gnap/gnap.cpp | 6 | ||||
-rw-r--r-- | engines/gnap/gnap.h | 123 | ||||
-rw-r--r-- | engines/gnap/scenes/scene51.cpp | 493 | ||||
-rw-r--r-- | engines/gnap/scenes/scene51.h | 101 | ||||
-rw-r--r-- | engines/gnap/scenes/scene52.cpp | 482 | ||||
-rw-r--r-- | engines/gnap/scenes/scene52.h | 118 | ||||
-rw-r--r-- | engines/gnap/scenes/scenecore.cpp | 14 |
7 files changed, 724 insertions, 613 deletions
diff --git a/engines/gnap/gnap.cpp b/engines/gnap/gnap.cpp index 5d4e8106ab..f6bff6025c 100644 --- a/engines/gnap/gnap.cpp +++ b/engines/gnap/gnap.cpp @@ -2021,12 +2021,6 @@ void GnapEngine::initGlobalSceneVars() { // Shared by scenes 17 && 18 _s18_garbageCanPos = 8; - // Scene 52 - _s52_gameScore = 0; - _s52_aliensInitialized = false; - _s52_alienDirection = 0; - _s52_soundToggle = false; - // Scene 53 _s53_callsMadeCtr = 0; _s53_callsRndUsed = 0; diff --git a/engines/gnap/gnap.h b/engines/gnap/gnap.h index bd1714dbbe..a80d82f3fc 100644 --- a/engines/gnap/gnap.h +++ b/engines/gnap/gnap.h @@ -250,17 +250,6 @@ enum { // 0x7AF Gnap walks to the left 1 // 0x7B0 Gnap walks to the left 2 -struct Scene51Item { - int _currSequenceId; - int _droppedSequenceId; - int _x, _y; - int _collisionX; - bool _canCatch; - bool _isCollision; - int _x2; - int _id; -}; - enum Facing { kDirNone = 0, kDirBottomRight = 1, @@ -601,118 +590,6 @@ public: bool toyUfoCheckTimer(); void toyUfoFlyTo(int destX, int destY, int minX, int maxX, int minY, int maxY, int animationIndex); - // Scene 51 - int _s51_cashAmount; - int _s51_digits[4]; - int _s51_digitSequenceIds[4]; - int _s51_guySequenceId, _s51_guyNextSequenceId; - int _s51_itemsCaughtCtr; - int _s51_dropSpeedTicks; - int _s51_nextDropItemKind, _s51_itemInsertX, _s51_itemInsertDirection; - int _s51_platypusSequenceId, _s51_platypusNextSequenceId, _s51_platypusJumpSequenceId; - bool _s51_dropLoseCash; - int _s51_itemsCtr,_s51_itemsCtr1, _s51_itemsCtr2; - Scene51Item _s51_items[6]; - - int scene51_init(); - void scene51_updateHotspots(); - void scene51_clearItem(Scene51Item *item); - void scene51_dropNextItem(); - void scene51_updateItemAnimations(); - int scene51_checkCollision(int sequenceId); - void scene51_updateItemAnimation(Scene51Item *item, int index); - void scene51_removeCollidedItems(); - int scene51_itemIsCaught(Scene51Item *item); - bool scene51_isJumpingRight(int sequenceId); - bool scene51_isJumpingLeft(int sequenceId); - bool scene51_isJumping(int sequenceId); - void scene51_waitForAnim(int animationIndex); - int scene51_getPosRight(int sequenceId); - int scene51_getPosLeft(int sequenceId); - void scene51_playIntroAnim(); - void scene51_updateGuyAnimation(); - int scene51_incCashAmount(int sequenceId); - void scene51_winMinigame(); - void scene51_playCashAppearAnim(); - void scene51_updateCash(int amount); - void scene51_drawDigit(int digit, int position); - void scene51_initCashDisplay(); - void scene51_run(); - - // Scene 52 - int _s52_liveAlienRows; - int _s52_gameScore; - bool _s52_soundToggle; - int _s52_arcadeScreenLeft; - int _s52_arcadeScreenRight; - int _s52_arcadeScreenBottom; - int _s52_shipsLeft; - int _s52_shieldSpriteIds[3]; - int _s52_shieldPosX[3]; - int _s52_shipPosX; - int _s52_shipCannonPosX, _s52_shipCannonPosY; - bool _s52_shipCannonFiring; - bool _s52_shipCannonFired; - int _s52_shipCannonWidth, _s52_shipCannonHeight; - int _s52_shipCannonTopY; - int _s52_shipMidX, _s52_shipMidY; - bool _s52_shipFlag; - bool _s52_aliensInitialized; - int _s52_alienSpeed, _s52_alienDirection; - int _s52_alienWidth, _s52_alienHeight; - int _s52_alienLeftX, _s52_alienTopY; - int _s52_alienRowDownCtr; - int _s52_alienRowKind[7]; - int _s52_alienRowAnims[7]; - int _s52_alienRowIds[7]; - int _s52_alienRowXOfs[7]; - int _s52_alienCannonFired[3]; - int _s52_alienCannonPosX[3]; - int _s52_alienCannonPosY[3]; - int _s52_alienCannonSequenceIds[3]; - int _s52_alienCannonIds[3]; - bool _s52_alienWave, _s52_alienSingle; - int _s52_alienCounter; - bool _s52_bottomAlienFlag; - int _s52_aliensCount; - int _s52_items[8][5]; - int _s52_nextUfoSequenceId, _s52_ufoSequenceId; - int scene52_init(); - void scene52_updateHotspots(); - void scene52_update(); - void scene52_initShipCannon(int bottomY); - void scene52_initAlienCannons(); - void scene52_fireShipCannon(int posX); - void scene52_fireAlienCannon(); - int scene52_getFreeShipCannon(); - int scene52_getFreeAlienCannon(); - void scene52_updateShipCannon(); - void scene52_updateAlienCannons(); - void scene52_initAliens(); - void scene52_initAlienRowKind(int rowNum, int alienKind); - void scene52_insertAlienRow(int rowNum); - void scene52_insertAlienRowAliens(int rowNum); - void scene52_updateAlienRow(int rowNum); - void scene52_moveDownAlienRow(); - int scene52_updateHitAlien(); - int scene52_getHitAlienNum(int rowNum); - int scene52_alienCannonHitShip(int cannonNum); - int scene52_alienCannonHitShield(int cannonNum); - bool scene52_shipCannonHitShield(int cannonNum); - bool scene52_shipCannonHitAlien(); - void scene52_shipExplode(); - bool scene52_checkAlienRow(int rowNum); - void scene52_updateAlienRowXOfs(); - void scene52_initAlienSize(); - void scene52_playSound(); - void scene52_updateAliens(); - void scene52_updateAlien(int rowNum); - void scene52_loseShip(); - void scene52_initShields(); - void scene52_initAnims(); - void scene52_drawScore(int score); - void scene52_run(); - // Scene 53 int _s53_currHandSequenceId; bool _s53_isGnapPhoning; diff --git a/engines/gnap/scenes/scene51.cpp b/engines/gnap/scenes/scene51.cpp index 1d9e177989..f4a3a843ba 100644 --- a/engines/gnap/scenes/scene51.cpp +++ b/engines/gnap/scenes/scene51.cpp @@ -23,6 +23,7 @@ #include "gnap/gnap.h" #include "gnap/gamesys.h" #include "gnap/resource.h" +#include "gnap/scenes/scene51.h" namespace Gnap { @@ -46,18 +47,54 @@ static const int kDigitPositions[4] = { 0x76 Platypus jumping (right) */ -int GnapEngine::scene51_init() { - _gameSys->setAnimation(0, 0, 0); +Scene51::Scene51(GnapEngine *vm) : Scene(vm) { + _s51_dropLoseCash = false; + + _s51_cashAmount = -1; + _s51_guySequenceId = -1; + _s51_guyNextSequenceId = -1; + _s51_itemsCaughtCtr = -1; + _s51_dropSpeedTicks = -1; + _s51_nextDropItemKind = -1; + _s51_itemInsertX = -1; + _s51_itemInsertDirection = -1; + _s51_platypusSequenceId = -1; + _s51_platypusNextSequenceId = -1; + _s51_platypusJumpSequenceId = -1; + _s51_itemsCtr = -1; + _s51_itemsCtr1 = -1; + _s51_itemsCtr2 = -1; + + for (int i = 0; i < 4; i++) { + _s51_digits[i] = 0; + _s51_digitSequenceIds[4] = -1; + } + + for (int i = 0; i < 6; i++) { + _s51_items[i]._currSequenceId = -1; + _s51_items[i]._droppedSequenceId; + _s51_items[i]._x = 0; + _s51_items[i]._y = 0; + _s51_items[i]._collisionX; + _s51_items[i]._canCatch = false; + _s51_items[i]._isCollision = false; + _s51_items[i]._x2 = 0; + _s51_items[i]._id = -1; + } +} + +int Scene51::init() { + _vm->_gameSys->setAnimation(0, 0, 0); for (int i = 0; i < 6; ++i) - _gameSys->setAnimation(0, 0, i + 1); + _vm->_gameSys->setAnimation(0, 0, i + 1); return 0xD4; } -void GnapEngine::scene51_updateHotspots() { - _hotspotsCount = 0; +void Scene51::updateHotspots() { + _vm->_hotspotsCount = 0; } -void GnapEngine::scene51_clearItem(Scene51Item *item) { +void Scene51::clearItem(Scene51Item *item) { item->_currSequenceId = 0; item->_droppedSequenceId = 0; item->_x = 0; @@ -67,13 +104,11 @@ void GnapEngine::scene51_clearItem(Scene51Item *item) { item->_canCatch = false; } -void GnapEngine::scene51_dropNextItem() { - - if (_timers[0]) +void Scene51::dropNextItem() { + if (_vm->_timers[0]) return; int index = 0; - while (index < 6 && _s51_items[index]._currSequenceId) ++index; @@ -81,9 +116,8 @@ void GnapEngine::scene51_dropNextItem() { return; switch (_s51_nextDropItemKind) { - case 0: - if (getRandom(10) != 0 || _s51_itemsCtr2 >= 2) { + if (_vm->getRandom(10) != 0 || _s51_itemsCtr2 >= 2) { _s51_items[index]._currSequenceId = 0xBD; } else { --_s51_itemsCtr1; @@ -93,8 +127,8 @@ void GnapEngine::scene51_dropNextItem() { break; case 1: - if (getRandom(8) != 0 || _s51_itemsCtr2 >= 2) { - if (getRandom(5) == 0) { + if (_vm->getRandom(8) != 0 || _s51_itemsCtr2 >= 2) { + if (_vm->getRandom(5) == 0) { if (_s51_itemInsertDirection) _s51_itemInsertX -= 70; else @@ -109,7 +143,7 @@ void GnapEngine::scene51_dropNextItem() { break; case 2: - if (getRandom(6) != 0 || _s51_itemsCtr2 >= 2) { + if (_vm->getRandom(6) != 0 || _s51_itemsCtr2 >= 2) { _s51_items[index]._currSequenceId = 0xBD; } else { --_s51_itemsCtr1; @@ -127,8 +161,8 @@ void GnapEngine::scene51_dropNextItem() { case 5: case 6: - if (getRandom(5) != 0 || _s51_itemsCtr2 >= 2) { - if (getRandom(5) != 0) + if (_vm->getRandom(5) != 0 || _s51_itemsCtr2 >= 2) { + if (_vm->getRandom(5) != 0) _s51_items[index]._currSequenceId = 0xBD; else _s51_items[index]._currSequenceId = 0xC0; @@ -140,14 +174,14 @@ void GnapEngine::scene51_dropNextItem() { break; case 7: - if (getRandom(5) != 0 || _s51_itemsCtr2 >= 2) { - if (getRandom(5) == 0) { + if (_vm->getRandom(5) != 0 || _s51_itemsCtr2 >= 2) { + if (_vm->getRandom(5) == 0) { if (_s51_itemInsertDirection) _s51_itemInsertX -= 40; else _s51_itemInsertX += 40; } - if (getRandom(9) != 0) + if (_vm->getRandom(9) != 0) _s51_items[index]._currSequenceId = 0xBD; else _s51_items[index]._currSequenceId = 0xC0; @@ -159,8 +193,8 @@ void GnapEngine::scene51_dropNextItem() { break; default: - if (getRandom(4) != 0 || _s51_itemsCtr2 >= 2) { - if (getRandom(9) != 0) + if (_vm->getRandom(4) != 0 || _s51_itemsCtr2 >= 2) { + if (_vm->getRandom(9) != 0) _s51_items[index]._currSequenceId = 0xBD; else _s51_items[index]._currSequenceId = 0xC0; @@ -170,7 +204,6 @@ void GnapEngine::scene51_dropNextItem() { ++_s51_itemsCtr2; } break; - } if (_s51_itemInsertDirection) { @@ -194,7 +227,7 @@ void GnapEngine::scene51_dropNextItem() { _s51_itemInsertX = 129; if (_s51_items[index]._currSequenceId == 0xBA) { - _s51_items[index]._x2 = getRandom(350) + 200; + _s51_items[index]._x2 = _vm->getRandom(350) + 200; _s51_items[index]._x = _s51_items[index]._x2 - 362; _s51_items[index]._y = 15; _s51_items[index]._id = 249 - index; @@ -207,37 +240,37 @@ void GnapEngine::scene51_dropNextItem() { _s51_items[index]._canCatch = true; } - _gameSys->setAnimation(_s51_items[index]._currSequenceId, _s51_items[index]._id, index + 1); - _gameSys->insertSequence(_s51_items[index]._currSequenceId, _s51_items[index]._id, 0, 0, + _vm->_gameSys->setAnimation(_s51_items[index]._currSequenceId, _s51_items[index]._id, index + 1); + _vm->_gameSys->insertSequence(_s51_items[index]._currSequenceId, _s51_items[index]._id, 0, 0, kSeqNone, 0, _s51_items[index]._x, _s51_items[index]._y); - _timers[0] = _s51_dropSpeedTicks; + _vm->_timers[0] = _s51_dropSpeedTicks; if (_s51_nextDropItemKind >= 3) - _timers[0] = 20; + _vm->_timers[0] = 20; if (_s51_nextDropItemKind >= 5) - _timers[0] = 5; + _vm->_timers[0] = 5; if (_s51_nextDropItemKind == 8) - _timers[0] = 4; + _vm->_timers[0] = 4; ++_s51_itemsCtr; - } -void GnapEngine::scene51_updateItemAnimations() { - for (int i = 0; i < 6; ++i) - if (_gameSys->getAnimationStatus(i + 1) == 2) - scene51_updateItemAnimation(&_s51_items[i], i); +void Scene51::updateItemAnimations() { + for (int i = 0; i < 6; ++i) { + if (_vm->_gameSys->getAnimationStatus(i + 1) == 2) + updateItemAnimation(&_s51_items[i], i); + } } -int GnapEngine::scene51_checkCollision(int sequenceId) { +int Scene51::checkCollision(int sequenceId) { bool jumpingLeft = false, jumpingRight = false; int v8, v4; int result = 0; - if (!scene51_isJumping(sequenceId)) + if (!isJumping(sequenceId)) return false; bool checkFl = false; @@ -247,13 +280,13 @@ int GnapEngine::scene51_checkCollision(int sequenceId) { if (!checkFl) return false; - if (scene51_isJumpingRight(sequenceId)) { - v8 = scene51_getPosRight(sequenceId); - v4 = scene51_getPosRight(sequenceId + 1); + if (isJumpingRight(sequenceId)) { + v8 = getPosRight(sequenceId); + v4 = getPosRight(sequenceId + 1); jumpingRight = true; - } else if (scene51_isJumpingLeft(sequenceId)) { - v4 = scene51_getPosLeft(sequenceId - 1) + 33; - v8 = scene51_getPosLeft(sequenceId) + 33; + } else if (isJumpingLeft(sequenceId)) { + v4 = getPosLeft(sequenceId - 1) + 33; + v8 = getPosLeft(sequenceId) + 33; jumpingLeft = true; } @@ -278,8 +311,8 @@ int GnapEngine::scene51_checkCollision(int sequenceId) { } } if (v5) { - _gameSys->setAnimation(0xBC, _s51_items[i]._id, i + 1); - _gameSys->insertSequence(0xBC, _s51_items[i]._id, _s51_items[i]._currSequenceId, _s51_items[i]._id, kSeqSyncWait, 0, _s51_items[i]._x, 15); + _vm->_gameSys->setAnimation(0xBC, _s51_items[i]._id, i + 1); + _vm->_gameSys->insertSequence(0xBC, _s51_items[i]._id, _s51_items[i]._currSequenceId, _s51_items[i]._id, kSeqSyncWait, 0, _s51_items[i]._x, 15); _s51_items[i]._isCollision = false; _s51_items[i]._currSequenceId = 0xBC; --_s51_itemsCtr2; @@ -290,14 +323,14 @@ int GnapEngine::scene51_checkCollision(int sequenceId) { return result; } -void GnapEngine::scene51_updateItemAnimation(Scene51Item *item, int index) { +void Scene51::updateItemAnimation(Scene51Item *item, int index) { switch (item->_currSequenceId) { case 0xBD: case 0xC0: case 0xC1: // Falling coin and banknote - if (!scene51_itemIsCaught(item)) { + if (!itemIsCaught(item)) { if (_s51_dropLoseCash) { if (item->_currSequenceId == 0xBD) _s51_cashAmount -= 2; @@ -305,30 +338,30 @@ void GnapEngine::scene51_updateItemAnimation(Scene51Item *item, int index) { _s51_cashAmount -= 25; if (_s51_cashAmount < 0) _s51_cashAmount = 0; - scene51_updateCash(_s51_cashAmount); + updateCash(_s51_cashAmount); } item->_droppedSequenceId = item->_currSequenceId + 1; if (item->_currSequenceId != 0xC0) { item->_canCatch = false; _s51_dropLoseCash = true; _s51_itemsCtr = 0; - _timers[0] = 10; + _vm->_timers[0] = 10; } if (item->_droppedSequenceId) { - _gameSys->setAnimation(item->_droppedSequenceId, item->_id, index + 1); - _gameSys->insertSequence(item->_droppedSequenceId, item->_id, item->_currSequenceId, item->_id, kSeqSyncWait, 0, item->_x, item->_y); + _vm->_gameSys->setAnimation(item->_droppedSequenceId, item->_id, index + 1); + _vm->_gameSys->insertSequence(item->_droppedSequenceId, item->_id, item->_currSequenceId, item->_id, kSeqSyncWait, 0, item->_x, item->_y); item->_currSequenceId = item->_droppedSequenceId; item->_y = 0; } } else { - _gameSys->removeSequence(item->_currSequenceId, item->_id, true); - _gameSys->setAnimation(0, 0, index + 1); - playSound(218, false); - if (scene51_incCashAmount(item->_currSequenceId) == 1995) { - scene51_winMinigame(); - _sceneDone = true; + _vm->_gameSys->removeSequence(item->_currSequenceId, item->_id, true); + _vm->_gameSys->setAnimation(0, 0, index + 1); + _vm->playSound(218, false); + if (incCashAmount(item->_currSequenceId) == 1995) { + winMinigame(); + _vm->_sceneDone = true; } else { - scene51_clearItem(item); + clearItem(item); ++_s51_itemsCaughtCtr; if (_s51_itemsCaughtCtr == 5) --_s51_dropSpeedTicks; @@ -347,7 +380,7 @@ void GnapEngine::scene51_updateItemAnimation(Scene51Item *item, int index) { _s51_itemsCtr1 = 20; _s51_dropLoseCash = false; _s51_itemsCaughtCtr = 0; - scene51_removeCollidedItems(); + removeCollidedItems(); } } } @@ -357,8 +390,8 @@ void GnapEngine::scene51_updateItemAnimation(Scene51Item *item, int index) { // Fallen coin item->_droppedSequenceId = item->_currSequenceId + 1; if (item->_droppedSequenceId) { - _gameSys->setAnimation(item->_droppedSequenceId, item->_id, index + 1); - _gameSys->insertSequence(item->_droppedSequenceId, item->_id, item->_currSequenceId, item->_id, kSeqSyncWait, 0, item->_x, item->_y); + _vm->_gameSys->setAnimation(item->_droppedSequenceId, item->_id, index + 1); + _vm->_gameSys->insertSequence(item->_droppedSequenceId, item->_id, item->_currSequenceId, item->_id, kSeqSyncWait, 0, item->_x, item->_y); item->_currSequenceId = item->_droppedSequenceId; item->_y = 0; } @@ -367,9 +400,9 @@ void GnapEngine::scene51_updateItemAnimation(Scene51Item *item, int index) { case 0xBF: case 0xC2: // Bouncing coin and banknote - _gameSys->setAnimation(0, 0, index + 1); - _gameSys->removeSequence(item->_currSequenceId, item->_id, true); - scene51_clearItem(item); + _vm->_gameSys->setAnimation(0, 0, index + 1); + _vm->_gameSys->removeSequence(item->_currSequenceId, item->_id, true); + clearItem(item); break; case 0xBA: @@ -377,8 +410,8 @@ void GnapEngine::scene51_updateItemAnimation(Scene51Item *item, int index) { item->_droppedSequenceId = 0xBB; item->_y = 15; if (item->_droppedSequenceId) { - _gameSys->setAnimation(item->_droppedSequenceId, item->_id, index + 1); - _gameSys->insertSequence(item->_droppedSequenceId, item->_id, item->_currSequenceId, item->_id, kSeqSyncWait, 0, item->_x, item->_y); + _vm->_gameSys->setAnimation(item->_droppedSequenceId, item->_id, index + 1); + _vm->_gameSys->insertSequence(item->_droppedSequenceId, item->_id, item->_currSequenceId, item->_id, kSeqSyncWait, 0, item->_x, item->_y); item->_currSequenceId = item->_droppedSequenceId; item->_y = 0; } @@ -387,60 +420,57 @@ void GnapEngine::scene51_updateItemAnimation(Scene51Item *item, int index) { case 0xBB: item->_isCollision = true; item->_droppedSequenceId = 0; - _gameSys->setAnimation(0, 0, index + 1); + _vm->_gameSys->setAnimation(0, 0, index + 1); break; case 0xBC: - _gameSys->removeSequence(item->_currSequenceId, item->_id, true); - _gameSys->setAnimation(0, 0, index + 1); - scene51_clearItem(item); + _vm->_gameSys->removeSequence(item->_currSequenceId, item->_id, true); + _vm->_gameSys->setAnimation(0, 0, index + 1); + clearItem(item); break; default: if (item->_droppedSequenceId) { - _gameSys->setAnimation(item->_droppedSequenceId, item->_id, index + 1); - _gameSys->insertSequence(item->_droppedSequenceId, item->_id, item->_currSequenceId, item->_id, kSeqSyncWait, 0, item->_x, item->_y); + _vm->_gameSys->setAnimation(item->_droppedSequenceId, item->_id, index + 1); + _vm->_gameSys->insertSequence(item->_droppedSequenceId, item->_id, item->_currSequenceId, item->_id, kSeqSyncWait, 0, item->_x, item->_y); item->_currSequenceId = item->_droppedSequenceId; item->_y = 0; } break; - } - } -void GnapEngine::scene51_removeCollidedItems() { +void Scene51::removeCollidedItems() { for (int i = 0; i < 6; ++i) { if (_s51_items[i]._isCollision) { - _gameSys->removeSequence(_s51_items[i]._currSequenceId, _s51_items[i]._id, true); - _gameSys->setAnimation(0, 0, i + 1); - scene51_clearItem(&_s51_items[i]); + _vm->_gameSys->removeSequence(_s51_items[i]._currSequenceId, _s51_items[i]._id, true); + _vm->_gameSys->setAnimation(0, 0, i + 1); + clearItem(&_s51_items[i]); } } _s51_itemsCtr2 = 0; } -int GnapEngine::scene51_itemIsCaught(Scene51Item *item) { - +int Scene51::itemIsCaught(Scene51Item *item) { if (!item->_canCatch) return 0; - if (scene51_isJumpingRight(_s51_platypusJumpSequenceId)) { - int v4 = scene51_getPosRight(_s51_platypusJumpSequenceId) + 97; + if (isJumpingRight(_s51_platypusJumpSequenceId)) { + int v4 = getPosRight(_s51_platypusJumpSequenceId) + 97; if (item->_collisionX < v4 && v4 - item->_collisionX < 56) return 1; } else { - int v2 = scene51_getPosLeft(_s51_platypusJumpSequenceId); + int v2 = getPosLeft(_s51_platypusJumpSequenceId); if (item->_collisionX > v2 && item->_collisionX - v2 < 56) return 1; } if (item->_currSequenceId == 0xC1) { int v3 = item->_collisionX + 100; - if (scene51_isJumpingRight(_s51_platypusJumpSequenceId)) { - if (ABS(scene51_getPosRight(_s51_platypusJumpSequenceId) + 46 - v3) < 56) + if (isJumpingRight(_s51_platypusJumpSequenceId)) { + if (ABS(getPosRight(_s51_platypusJumpSequenceId) + 46 - v3) < 56) return 1; - } else if (ABS(scene51_getPosLeft(_s51_platypusJumpSequenceId) + 46 - v3) < 56) { + } else if (ABS(getPosLeft(_s51_platypusJumpSequenceId) + 46 - v3) < 56) { return 1; } } @@ -448,27 +478,27 @@ int GnapEngine::scene51_itemIsCaught(Scene51Item *item) { return 0; } -bool GnapEngine::scene51_isJumpingRight(int sequenceId) { +bool Scene51::isJumpingRight(int sequenceId) { return sequenceId >= 0x76 && sequenceId <= 0x95; } -bool GnapEngine::scene51_isJumpingLeft(int sequenceId) { +bool Scene51::isJumpingLeft(int sequenceId) { return sequenceId >= 0x96 && sequenceId <= 0xB5; } -bool GnapEngine::scene51_isJumping(int sequenceId) { +bool Scene51::isJumping(int sequenceId) { return sequenceId >= 0x76 && sequenceId <= 0xB5; } -void GnapEngine::scene51_waitForAnim(int animationIndex) { - while (_gameSys->getAnimationStatus(animationIndex) != 2) { +void Scene51::waitForAnim(int animationIndex) { + while (_vm->_gameSys->getAnimationStatus(animationIndex) != 2) { // pollMessages(); - scene51_updateItemAnimations(); - gameUpdateTick(); + updateItemAnimations(); + _vm->gameUpdateTick(); } } -int GnapEngine::scene51_getPosRight(int sequenceId) { +int Scene51::getPosRight(int sequenceId) { static const int kRightPosTbl[] = { 131, 159, 178, 195, 203, 219, 238, 254, 246, 274, 293, 310, 318, 334, 353, 369, @@ -481,7 +511,7 @@ int GnapEngine::scene51_getPosRight(int sequenceId) { return -1; } -int GnapEngine::scene51_getPosLeft(int sequenceId) { +int Scene51::getPosLeft(int sequenceId) { static const int kLeftPosTbl[] = { 580, 566, 550, 536, 526, 504, 488, 469, 460, 446, 430, 416, 406, 384, 368, 349, @@ -494,14 +524,14 @@ int GnapEngine::scene51_getPosLeft(int sequenceId) { return -1; } -void GnapEngine::scene51_playIntroAnim() { +void Scene51::playIntroAnim() { int soundCtr = 0; _s51_platypusSequenceId = 0x76; _s51_platypusNextSequenceId = 0x76; for (int i = 0; i < 6; ++i) - scene51_clearItem(&_s51_items[i]); + clearItem(&_s51_items[i]); _s51_items[0]._currSequenceId = 0xBA; _s51_items[0]._x2 = 320; @@ -510,51 +540,48 @@ void GnapEngine::scene51_playIntroAnim() { _s51_items[0]._id = 249; _s51_items[0]._isCollision = true; - _gameSys->insertSequence(_s51_platypusSequenceId, 256, 0, 0, kSeqNone, 0, -179, 0); - _gameSys->insertSequence(0xBA, 249, 0, 0, kSeqNone, 0, _s51_items[0]._x, _s51_items[0]._y); - _gameSys->setAnimation(0xBA, 249, 1); - _gameSys->setAnimation(_s51_platypusSequenceId, 256, 0); + _vm->_gameSys->insertSequence(_s51_platypusSequenceId, 256, 0, 0, kSeqNone, 0, -179, 0); + _vm->_gameSys->insertSequence(0xBA, 249, 0, 0, kSeqNone, 0, _s51_items[0]._x, _s51_items[0]._y); + _vm->_gameSys->setAnimation(0xBA, 249, 1); + _vm->_gameSys->setAnimation(_s51_platypusSequenceId, 256, 0); while (_s51_platypusSequenceId < 0x80) { - scene51_waitForAnim(0); + waitForAnim(0); ++_s51_platypusNextSequenceId; - _gameSys->setAnimation(_s51_platypusNextSequenceId, 256, 0); - _gameSys->insertSequence(_s51_platypusNextSequenceId, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, -179, 0); + _vm->_gameSys->setAnimation(_s51_platypusNextSequenceId, 256, 0); + _vm->_gameSys->insertSequence(_s51_platypusNextSequenceId, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, -179, 0); _s51_platypusSequenceId = _s51_platypusNextSequenceId; ++soundCtr; if (soundCtr % 4 == 0) - playSound(214, false); + _vm->playSound(214, false); } _s51_platypusNextSequenceId = 0x75; while (_s51_platypusSequenceId != 0x84) { - scene51_waitForAnim(0); + waitForAnim(0); ++_s51_platypusNextSequenceId; int oldSequenceId = _s51_platypusNextSequenceId; - int v0 = scene51_checkCollision(_s51_platypusNextSequenceId); - _gameSys->setAnimation(_s51_platypusNextSequenceId, 256, 0); - _gameSys->insertSequence(_s51_platypusNextSequenceId, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, v0, 0); + int v0 = checkCollision(_s51_platypusNextSequenceId); + _vm->_gameSys->setAnimation(_s51_platypusNextSequenceId, 256, 0); + _vm->_gameSys->insertSequence(_s51_platypusNextSequenceId, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, v0, 0); _s51_platypusSequenceId = _s51_platypusNextSequenceId; if (v0) { _s51_platypusNextSequenceId = oldSequenceId; } else { ++soundCtr; if (soundCtr % 4 == 0) - playSound(214, false); + _vm->playSound(214, false); } } - - scene51_waitForAnim(0); - + waitForAnim(0); } -void GnapEngine::scene51_updateGuyAnimation() { - - if (!_timers[4]) { - _timers[4] = getRandom(20) + 60; +void Scene51::updateGuyAnimation() { + if (!_vm->_timers[4]) { + _vm->_timers[4] = _vm->getRandom(20) + 60; - switch (getRandom(5)) { + switch (_vm->getRandom(5)) { case 0: _s51_guyNextSequenceId = 0xC3; break; @@ -572,15 +599,13 @@ void GnapEngine::scene51_updateGuyAnimation() { break; } - _gameSys->insertSequence(_s51_guyNextSequenceId, 39, _s51_guySequenceId, 39, kSeqSyncWait, 0, 0, 0); + _vm->_gameSys->insertSequence(_s51_guyNextSequenceId, 39, _s51_guySequenceId, 39, kSeqSyncWait, 0, 0, 0); _s51_guySequenceId = _s51_guyNextSequenceId; _s51_guyNextSequenceId = -1; - } - } -int GnapEngine::scene51_incCashAmount(int sequenceId) { +int Scene51::incCashAmount(int sequenceId) { switch (sequenceId) { case 0xBD: _s51_cashAmount += 10; @@ -591,44 +616,44 @@ int GnapEngine::scene51_incCashAmount(int sequenceId) { break; case 0xB6: case 0xB7: - _s51_cashAmount -= 10 * getRandom(5) + 50; + _s51_cashAmount -= 10 * _vm->getRandom(5) + 50; if (_s51_cashAmount < 0) _s51_cashAmount = 0; break; } if (_s51_cashAmount > 1995) _s51_cashAmount = 1995; - scene51_updateCash(_s51_cashAmount); + updateCash(_s51_cashAmount); return _s51_cashAmount; } -void GnapEngine::scene51_winMinigame() { - scene51_updateCash(1995); - playSound(218, false); +void Scene51::winMinigame() { + updateCash(1995); + _vm->playSound(218, false); // TODO delayTicksA(1, 5); - _newSceneNum = 48; - invRemove(kItemBanana); + _vm->_newSceneNum = 48; + _vm->invRemove(kItemBanana); } -void GnapEngine::scene51_playCashAppearAnim() { - _gameSys->setAnimation(0xC8, 252, 0); - _gameSys->insertSequence(0xC8, 252, 0, 0, kSeqNone, 0, -20, -20); - while (_gameSys->getAnimationStatus(0) != 2) { - gameUpdateTick(); +void Scene51::playCashAppearAnim() { + _vm->_gameSys->setAnimation(0xC8, 252, 0); + _vm->_gameSys->insertSequence(0xC8, 252, 0, 0, kSeqNone, 0, -20, -20); + while (_vm->_gameSys->getAnimationStatus(0) != 2) { + _vm->gameUpdateTick(); // checkGameAppStatus(); } } -void GnapEngine::scene51_updateCash(int amount) { - scene51_drawDigit(amount / 1000, 0); - scene51_drawDigit(amount / 100 % 10, 1); - scene51_drawDigit(amount / 10 % 10, 2); - scene51_drawDigit(amount % 10, 3); +void Scene51::updateCash(int amount) { + drawDigit(amount / 1000, 0); + drawDigit(amount / 100 % 10, 1); + drawDigit(amount / 10 % 10, 2); + drawDigit(amount % 10, 3); } -void GnapEngine::scene51_drawDigit(int digit, int position) { +void Scene51::drawDigit(int digit, int position) { if (digit != _s51_digits[position]) { - _gameSys->insertSequence(kDigitSequenceIds[digit], 253, + _vm->_gameSys->insertSequence(kDigitSequenceIds[digit], 253, _s51_digitSequenceIds[position], 253, kSeqSyncWait, 0, kDigitPositions[position] - 20, -20); _s51_digitSequenceIds[position] = kDigitSequenceIds[digit]; @@ -636,44 +661,42 @@ void GnapEngine::scene51_drawDigit(int digit, int position) { } } -void GnapEngine::scene51_initCashDisplay() { +void Scene51::initCashDisplay() { for (int position = 0; position < 4; ++position) { _s51_digits[position] = 0; _s51_digitSequenceIds[position] = kDigitSequenceIds[0]; - _gameSys->insertSequence(kDigitSequenceIds[0], 253, 0, 0, + _vm->_gameSys->insertSequence(kDigitSequenceIds[0], 253, 0, 0, kSeqNone, 0, kDigitPositions[position] - 20, -20); } _s51_cashAmount = 0; } -void GnapEngine::scene51_run() { - +void Scene51::run() { int soundCtr = 0; bool isIdle = true; _s51_itemsCtr = 0; - _newSceneNum = _prevSceneNum; + _vm->_newSceneNum = _vm->_prevSceneNum; _s51_cashAmount = 0; _s51_platypusJumpSequenceId = 0x84; - endSceneInit(); + _vm->endSceneInit(); - hideCursor(); - setGrabCursorSprite(-1); + _vm->hideCursor(); + _vm->setGrabCursorSprite(-1); _s51_guySequenceId = 0xC3; _s51_guyNextSequenceId = -1; - _gameSys->insertSequence(0xC3, 39, 0, 0, kSeqNone, 0, 0, 0); + _vm->_gameSys->insertSequence(0xC3, 39, 0, 0, kSeqNone, 0, 0, 0); + _vm->_timers[4] = _vm->getRandom(20) + 60; - _timers[4] = getRandom(20) + 60; - - scene51_playCashAppearAnim(); - scene51_initCashDisplay(); - scene51_playIntroAnim(); + playCashAppearAnim(); + initCashDisplay(); + playIntroAnim(); _s51_platypusNextSequenceId = 0x74; - _gameSys->setAnimation(0x74, 256, 0); - _gameSys->insertSequence(_s51_platypusNextSequenceId, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, scene51_getPosRight(_s51_platypusJumpSequenceId) - 362, 0); + _vm->_gameSys->setAnimation(0x74, 256, 0); + _vm->_gameSys->insertSequence(_s51_platypusNextSequenceId, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, getPosRight(_s51_platypusJumpSequenceId) - 362, 0); _s51_platypusSequenceId = _s51_platypusNextSequenceId; _s51_itemInsertDirection = 0; @@ -682,55 +705,53 @@ void GnapEngine::scene51_run() { _s51_nextDropItemKind = 0; for (int i = 0; i < 6; ++i) - scene51_clearItem(&_s51_items[i]); - - _s51_itemInsertX = getRandom(556) + 129; + clearItem(&_s51_items[i]); - _timers[0] = 15; + _s51_itemInsertX = _vm->getRandom(556) + 129; + _vm->_timers[0] = 15; _s51_itemsCaughtCtr = 0; _s51_dropLoseCash = false; _s51_itemsCtr1 = 20; - clearKeyStatus1(Common::KEYCODE_RIGHT); - clearKeyStatus1(Common::KEYCODE_LEFT); - clearKeyStatus1(Common::KEYCODE_UP); - clearKeyStatus1(Common::KEYCODE_SPACE); - clearKeyStatus1(Common::KEYCODE_ESCAPE); + _vm->clearKeyStatus1(Common::KEYCODE_RIGHT); + _vm->clearKeyStatus1(Common::KEYCODE_LEFT); + _vm->clearKeyStatus1(Common::KEYCODE_UP); + _vm->clearKeyStatus1(Common::KEYCODE_SPACE); + _vm->clearKeyStatus1(Common::KEYCODE_ESCAPE); bool isCollision = false; bool startWalk = true; - while (!_sceneDone) { + while (!_vm->_sceneDone) { + if (_vm->sceneXX_sub_4466B1()) + _vm->_sceneDone = true; - if (sceneXX_sub_4466B1()) - _sceneDone = true; + _vm->gameUpdateTick(); - gameUpdateTick(); + updateGuyAnimation(); + dropNextItem(); + updateItemAnimations(); - scene51_updateGuyAnimation(); - scene51_dropNextItem(); - scene51_updateItemAnimations(); - - if (isKeyStatus2(Common::KEYCODE_UP) || isKeyStatus2(Common::KEYCODE_SPACE)) { - clearKeyStatus1(Common::KEYCODE_UP); - clearKeyStatus1(Common::KEYCODE_SPACE); - if (scene51_isJumpingRight(_s51_platypusJumpSequenceId)) { - scene51_waitForAnim(0); - _gameSys->setAnimation(0xB8, 256, 0); - _gameSys->insertSequence(0xB8, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, scene51_getPosRight(_s51_platypusJumpSequenceId) - 348, 0); + if (_vm->isKeyStatus2(Common::KEYCODE_UP) || _vm->isKeyStatus2(Common::KEYCODE_SPACE)) { + _vm->clearKeyStatus1(Common::KEYCODE_UP); + _vm->clearKeyStatus1(Common::KEYCODE_SPACE); + if (isJumpingRight(_s51_platypusJumpSequenceId)) { + waitForAnim(0); + _vm->_gameSys->setAnimation(0xB8, 256, 0); + _vm->_gameSys->insertSequence(0xB8, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, getPosRight(_s51_platypusJumpSequenceId) - 348, 0); _s51_platypusSequenceId = 0xB8; - scene51_waitForAnim(0); + waitForAnim(0); _s51_platypusNextSequenceId += 6; if (_s51_platypusNextSequenceId > 0x95) _s51_platypusNextSequenceId = 0x95; _s51_platypusJumpSequenceId = _s51_platypusNextSequenceId; } else { - scene51_waitForAnim(0); - _gameSys->setAnimation(0xB9, 256, 0); - _gameSys->insertSequence(0xB9, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, scene51_getPosLeft(_s51_platypusJumpSequenceId) - 338, 0); + waitForAnim(0); + _vm->_gameSys->setAnimation(0xB9, 256, 0); + _vm->_gameSys->insertSequence(0xB9, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, getPosLeft(_s51_platypusJumpSequenceId) - 338, 0); _s51_platypusSequenceId = 0xB9; - scene51_waitForAnim(0); + waitForAnim(0); _s51_platypusNextSequenceId += 6; if (_s51_platypusNextSequenceId > 0xB5) _s51_platypusNextSequenceId = 0xB5; @@ -739,22 +760,22 @@ void GnapEngine::scene51_run() { isIdle = false; } - while (isKeyStatus2(Common::KEYCODE_RIGHT) && _s51_platypusNextSequenceId != 0x96) { + while (_vm->isKeyStatus2(Common::KEYCODE_RIGHT) && _s51_platypusNextSequenceId != 0x96) { // pollMessages(); if (_s51_platypusNextSequenceId == 0xB6) _s51_platypusNextSequenceId = 0x76; - scene51_updateItemAnimations(); + updateItemAnimations(); if (startWalk) { _s51_platypusNextSequenceId = 0x86; startWalk = false; } - if (_gameSys->getAnimationStatus(0) == 2) { - int collisionX = scene51_checkCollision(_s51_platypusNextSequenceId); + if (_vm->_gameSys->getAnimationStatus(0) == 2) { + int collisionX = checkCollision(_s51_platypusNextSequenceId); if (collisionX) - scene51_incCashAmount(_s51_platypusNextSequenceId); - _gameSys->setAnimation(_s51_platypusNextSequenceId, 256, 0); - _gameSys->insertSequence(_s51_platypusNextSequenceId, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, collisionX, 0); + incCashAmount(_s51_platypusNextSequenceId); + _vm->_gameSys->setAnimation(_s51_platypusNextSequenceId, 256, 0); + _vm->_gameSys->insertSequence(_s51_platypusNextSequenceId, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, collisionX, 0); _s51_platypusSequenceId = _s51_platypusNextSequenceId; if (collisionX) { isCollision = true; @@ -763,17 +784,17 @@ void GnapEngine::scene51_run() { } else { _s51_platypusJumpSequenceId = _s51_platypusNextSequenceId; } - if (scene51_isJumpingRight(_s51_platypusJumpSequenceId)) { + if (isJumpingRight(_s51_platypusJumpSequenceId)) { ++_s51_platypusNextSequenceId; if (!isCollision) { - if (isKeyStatus2(Common::KEYCODE_UP) || isKeyStatus2(Common::KEYCODE_SPACE)) { - clearKeyStatus1(Common::KEYCODE_UP); - clearKeyStatus1(Common::KEYCODE_SPACE); - scene51_waitForAnim(0); - _gameSys->setAnimation(0xB8, 256, 0); - _gameSys->insertSequence(0xB8, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, scene51_getPosRight(_s51_platypusJumpSequenceId) - 348, 0); + if (_vm->isKeyStatus2(Common::KEYCODE_UP) || _vm->isKeyStatus2(Common::KEYCODE_SPACE)) { + _vm->clearKeyStatus1(Common::KEYCODE_UP); + _vm->clearKeyStatus1(Common::KEYCODE_SPACE); + waitForAnim(0); + _vm->_gameSys->setAnimation(0xB8, 256, 0); + _vm->_gameSys->insertSequence(0xB8, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, getPosRight(_s51_platypusJumpSequenceId) - 348, 0); _s51_platypusSequenceId = 0xB8; - scene51_waitForAnim(0); + waitForAnim(0); _s51_platypusNextSequenceId += 6; if (_s51_platypusNextSequenceId > 0x95) _s51_platypusNextSequenceId = 0x95; @@ -781,7 +802,7 @@ void GnapEngine::scene51_run() { } else { ++soundCtr; if (soundCtr % 4 == 0) - playSound(214, false); + _vm->playSound(214, false); } } } else { @@ -790,23 +811,23 @@ void GnapEngine::scene51_run() { isCollision = false; isIdle = false; } - gameUpdateTick(); + _vm->gameUpdateTick(); } - while (isKeyStatus2(Common::KEYCODE_LEFT) && _s51_platypusNextSequenceId != 0xB6) { + while (_vm->isKeyStatus2(Common::KEYCODE_LEFT) && _s51_platypusNextSequenceId != 0xB6) { // pollMessages(); - scene51_updateItemAnimations(); + updateItemAnimations(); if (startWalk) { _s51_platypusNextSequenceId = 0xA5; startWalk = false; } - if (_gameSys->getAnimationStatus(0) == 2) { - int collisionX = scene51_checkCollision(_s51_platypusNextSequenceId); + if (_vm->_gameSys->getAnimationStatus(0) == 2) { + int collisionX = checkCollision(_s51_platypusNextSequenceId); if (collisionX) - scene51_incCashAmount(_s51_platypusNextSequenceId); - _gameSys->setAnimation(_s51_platypusNextSequenceId, 256, 0); - _gameSys->insertSequence(_s51_platypusNextSequenceId, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, collisionX, 0); + incCashAmount(_s51_platypusNextSequenceId); + _vm->_gameSys->setAnimation(_s51_platypusNextSequenceId, 256, 0); + _vm->_gameSys->insertSequence(_s51_platypusNextSequenceId, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, collisionX, 0); _s51_platypusSequenceId = _s51_platypusNextSequenceId; if (collisionX) { isCollision = true; @@ -815,17 +836,17 @@ void GnapEngine::scene51_run() { } else { _s51_platypusJumpSequenceId = _s51_platypusNextSequenceId; } - if (scene51_isJumpingLeft(_s51_platypusJumpSequenceId)) { + if (isJumpingLeft(_s51_platypusJumpSequenceId)) { ++_s51_platypusNextSequenceId; if (!isCollision) { - if (isKeyStatus2(Common::KEYCODE_UP) || isKeyStatus2(Common::KEYCODE_SPACE)) { - clearKeyStatus1(Common::KEYCODE_UP); - clearKeyStatus1(Common::KEYCODE_SPACE); - scene51_waitForAnim(0); - _gameSys->setAnimation(0xB9, 256, 0); - _gameSys->insertSequence(0xB9, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, scene51_getPosLeft(_s51_platypusJumpSequenceId) - 338, 0); + if (_vm->isKeyStatus2(Common::KEYCODE_UP) || _vm->isKeyStatus2(Common::KEYCODE_SPACE)) { + _vm->clearKeyStatus1(Common::KEYCODE_UP); + _vm->clearKeyStatus1(Common::KEYCODE_SPACE); + waitForAnim(0); + _vm->_gameSys->setAnimation(0xB9, 256, 0); + _vm->_gameSys->insertSequence(0xB9, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, getPosLeft(_s51_platypusJumpSequenceId) - 338, 0); _s51_platypusSequenceId = 0xB9; - scene51_waitForAnim(0); + waitForAnim(0); _s51_platypusNextSequenceId += 6; if (_s51_platypusNextSequenceId > 0xB5) _s51_platypusNextSequenceId = 0xB5; @@ -833,7 +854,7 @@ void GnapEngine::scene51_run() { } else { ++soundCtr; if (soundCtr % 4 == 0) - playSound(214, false); + _vm->playSound(214, false); } } } else { @@ -842,37 +863,35 @@ void GnapEngine::scene51_run() { isCollision = false; isIdle = false; } - gameUpdateTick(); + _vm->gameUpdateTick(); } - if (!isIdle && _gameSys->getAnimationStatus(0) == 2) { - if (scene51_isJumpingRight(_s51_platypusJumpSequenceId)) { - _gameSys->setAnimation(0x74, 256, 0); - _gameSys->insertSequence(0x74, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, scene51_getPosRight(_s51_platypusJumpSequenceId) - 362, 0); + if (!isIdle && _vm->_gameSys->getAnimationStatus(0) == 2) { + if (isJumpingRight(_s51_platypusJumpSequenceId)) { + _vm->_gameSys->setAnimation(0x74, 256, 0); + _vm->_gameSys->insertSequence(0x74, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, getPosRight(_s51_platypusJumpSequenceId) - 362, 0); _s51_platypusSequenceId = 0x74; } else { - _gameSys->setAnimation(0x75, 256, 0); - _gameSys->insertSequence(0x75, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, scene51_getPosLeft(_s51_platypusJumpSequenceId) - 341, 0); + _vm->_gameSys->setAnimation(0x75, 256, 0); + _vm->_gameSys->insertSequence(0x75, 256, _s51_platypusSequenceId, 256, kSeqSyncWait, 0, getPosLeft(_s51_platypusJumpSequenceId) - 341, 0); _s51_platypusSequenceId = 0x75; } - scene51_waitForAnim(0); + waitForAnim(0); isIdle = true; } - } - clearKeyStatus1(Common::KEYCODE_ESCAPE); - clearKeyStatus1(Common::KEYCODE_UP); - clearKeyStatus1(Common::KEYCODE_SPACE); - clearKeyStatus1(Common::KEYCODE_RIGHT); - clearKeyStatus1(Common::KEYCODE_LEFT); + _vm->clearKeyStatus1(Common::KEYCODE_ESCAPE); + _vm->clearKeyStatus1(Common::KEYCODE_UP); + _vm->clearKeyStatus1(Common::KEYCODE_SPACE); + _vm->clearKeyStatus1(Common::KEYCODE_RIGHT); + _vm->clearKeyStatus1(Common::KEYCODE_LEFT); - _gameSys->setAnimation(0, 0, 0); + _vm->_gameSys->setAnimation(0, 0, 0); for (int i = 0; i < 6; ++i) - _gameSys->setAnimation(0, 0, i + 1); - - showCursor(); + _vm->_gameSys->setAnimation(0, 0, i + 1); + _vm->showCursor(); } } // End of namespace Gnap diff --git a/engines/gnap/scenes/scene51.h b/engines/gnap/scenes/scene51.h new file mode 100644 index 0000000000..44fbd3d4d1 --- /dev/null +++ b/engines/gnap/scenes/scene51.h @@ -0,0 +1,101 @@ +/* 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_SCENE51_H +#define GNAP_SCENE51_H + +#include "gnap/debugger.h" +#include "gnap/scenes/scenecore.h" + +namespace Gnap { + +class GnapEngine; + +struct Scene51Item { + int _currSequenceId; + int _droppedSequenceId; + int _x, _y; + int _collisionX; + bool _canCatch; + bool _isCollision; + int _x2; + int _id; +}; + +class Scene51: public Scene { +public: + Scene51(GnapEngine *vm); + ~Scene51() {} + + virtual int init(); + virtual void updateHotspots(); + virtual void run(); + virtual void updateAnimations() {}; + virtual void updateAnimationsCb() {}; + +private: + bool _s51_dropLoseCash; + + int _s51_cashAmount; + int _s51_digits[4]; + int _s51_digitSequenceIds[4]; + int _s51_guySequenceId; + int _s51_guyNextSequenceId; + int _s51_itemsCaughtCtr; + int _s51_dropSpeedTicks; + int _s51_nextDropItemKind; + int _s51_itemInsertX; + int _s51_itemInsertDirection; + int _s51_platypusSequenceId; + int _s51_platypusNextSequenceId; + int _s51_platypusJumpSequenceId; + int _s51_itemsCtr; + int _s51_itemsCtr1; + int _s51_itemsCtr2; + + Scene51Item _s51_items[6]; + + void clearItem(Scene51Item *item); + void dropNextItem(); + void updateItemAnimations(); + int checkCollision(int sequenceId); + void updateItemAnimation(Scene51Item *item, int index); + void removeCollidedItems(); + int itemIsCaught(Scene51Item *item); + bool isJumpingRight(int sequenceId); + bool isJumpingLeft(int sequenceId); + bool isJumping(int sequenceId); + void waitForAnim(int animationIndex); + int getPosRight(int sequenceId); + int getPosLeft(int sequenceId); + void playIntroAnim(); + void updateGuyAnimation(); + int incCashAmount(int sequenceId); + void winMinigame(); + void playCashAppearAnim(); + void updateCash(int amount); + void drawDigit(int digit, int position); + void initCashDisplay(); +}; + +} // End of namespace Gnap +#endif // GNAP_SCENE51_H diff --git a/engines/gnap/scenes/scene52.cpp b/engines/gnap/scenes/scene52.cpp index 3d74538b27..fb16184742 100644 --- a/engines/gnap/scenes/scene52.cpp +++ b/engines/gnap/scenes/scene52.cpp @@ -23,96 +23,103 @@ #include "gnap/gnap.h" #include "gnap/gamesys.h" #include "gnap/resource.h" +#include "gnap/scenes/scene52.h" namespace Gnap { -int GnapEngine::scene52_init() { - scene52_initAnims(); +Scene52::Scene52(GnapEngine *vm) : Scene(vm) { + _s52_gameScore = 0; + _s52_aliensInitialized = false; + _s52_alienDirection = 0; + _s52_soundToggle = false; +} + +int Scene52::init() { + initAnims(); return 0x2B; } -void GnapEngine::scene52_updateHotspots() { - _hotspotsCount = 0; +void Scene52::updateHotspots() { + _vm->_hotspotsCount = 0; } -void GnapEngine::scene52_update() { - +void Scene52::update() { for (int rowNum = 0; rowNum < 7; ++rowNum) { - gameUpdateTick(); - if (_gameSys->getAnimationStatus(_s52_alienRowAnims[rowNum]) == 2) { - scene52_updateAlienRow(rowNum); + _vm->gameUpdateTick(); + if (_vm->_gameSys->getAnimationStatus(_s52_alienRowAnims[rowNum]) == 2) { + updateAlienRow(rowNum); rowNum = 0; } } if (_s52_liveAlienRows == 0 && !_s52_alienSingle) { _s52_alienWave = false; - playSound(48, false); + _vm->playSound(48, false); ++_s52_alienCounter; if (_s52_alienCounter != 3) { - _timers[0] = 50; - _timers[2] = 100; + _vm->_timers[0] = 50; + _vm->_timers[2] = 100; _s52_alienRowDownCtr = 0; _s52_alienSingle = true; } } - if (_s52_alienSingle && !_timers[0]) { - scene52_initAliens(); + if (_s52_alienSingle && !_vm->_timers[0]) { + initAliens(); _s52_alienSingle = false; - _timers[2] = 5; + _vm->_timers[2] = 5; _s52_alienWave = true; } if ((_s52_alienRowDownCtr || _s52_liveAlienRows == 0) && !_s52_alienSingle) { - scene52_moveDownAlienRow(); + moveDownAlienRow(); _s52_alienRowDownCtr = 0; } - if (isKeyStatus1(Common::KEYCODE_UP) || isKeyStatus1(Common::KEYCODE_SPACE)) { - clearKeyStatus1(Common::KEYCODE_SPACE); - clearKeyStatus1(Common::KEYCODE_UP); + if (_vm->isKeyStatus1(Common::KEYCODE_UP) || _vm->isKeyStatus1(Common::KEYCODE_SPACE)) { + _vm->clearKeyStatus1(Common::KEYCODE_SPACE); + _vm->clearKeyStatus1(Common::KEYCODE_UP); if (!_s52_aliensCount) - scene52_fireShipCannon(_s52_shipPosX); + fireShipCannon(_s52_shipPosX); } if (_s52_shipCannonFiring) - scene52_updateShipCannon(); + updateShipCannon(); - scene52_fireAlienCannon(); - scene52_updateAlienCannons(); + fireAlienCannon(); + updateAlienCannons(); if (_s52_aliensCount == 1) { _s52_alienWave = false; - _timers[3] = 20; - _timers[2] = 100; + _vm->_timers[3] = 20; + _vm->_timers[2] = 100; ++_s52_aliensCount; } - if (_s52_aliensCount && !_timers[3]) { - scene52_updateAliens(); - scene52_loseShip(); + if (_s52_aliensCount && !_vm->_timers[3]) { + updateAliens(); + loseShip(); if (_s52_shipsLeft != 0) { - _timers[3] = 40; - while (_timers[3]) { - scene52_updateAlienCannons(); + _vm->_timers[3] = 40; + while (_vm->_timers[3]) { + updateAlienCannons(); if (_s52_shipCannonFiring) - scene52_updateShipCannon(); - gameUpdateTick(); + updateShipCannon(); + _vm->gameUpdateTick(); } - scene52_initAliens(); + initAliens(); _s52_shipPosX = (800 - _s52_shipMidX) / 2; - _gameSys->setAnimation(_s52_nextUfoSequenceId, 256, 7); - _gameSys->insertSequence(_s52_nextUfoSequenceId, 256, 0, 0, kSeqNone, 0, _s52_shipPosX, _s52_arcadeScreenBottom); + _vm->_gameSys->setAnimation(_s52_nextUfoSequenceId, 256, 7); + _vm->_gameSys->insertSequence(_s52_nextUfoSequenceId, 256, 0, 0, kSeqNone, 0, _s52_shipPosX, _s52_arcadeScreenBottom); _s52_ufoSequenceId = _s52_nextUfoSequenceId; - _timers[2] = 5; + _vm->_timers[2] = 5; _s52_alienWave = true; } else { - _sceneDone = true; + _vm->_sceneDone = true; } } - if (_timers[1] || scene52_getFreeShipCannon() == -1) { + if (_vm->_timers[1] || getFreeShipCannon() == -1) { _s52_nextUfoSequenceId = 34; if (_s52_ufoSequenceId != 34) _s52_shipFlag = true; @@ -123,35 +130,35 @@ void GnapEngine::scene52_update() { } if (_s52_shipFlag) { - if (_gameSys->getAnimationStatus(7) == 2) { - _gameSys->setAnimation(_s52_nextUfoSequenceId, 256, 7); - _gameSys->insertSequence(_s52_nextUfoSequenceId, 256, _s52_ufoSequenceId, 256, kSeqSyncWait, 0, _s52_shipPosX, _s52_arcadeScreenBottom); + if (_vm->_gameSys->getAnimationStatus(7) == 2) { + _vm->_gameSys->setAnimation(_s52_nextUfoSequenceId, 256, 7); + _vm->_gameSys->insertSequence(_s52_nextUfoSequenceId, 256, _s52_ufoSequenceId, 256, kSeqSyncWait, 0, _s52_shipPosX, _s52_arcadeScreenBottom); _s52_ufoSequenceId = _s52_nextUfoSequenceId; } _s52_shipFlag = false; } - if (_s52_alienWave && !_timers[0]) { - scene52_playSound(); + if (_s52_alienWave && !_vm->_timers[0]) { + playSound(); int v0 = _s52_alienSpeed; if (_s52_alienSpeed >= 10) v0 = 10; int v1 = v0; if (v0 < 2) v1 = 2; - _timers[0] = v1; + _vm->_timers[0] = v1; } } -void GnapEngine::scene52_initShipCannon(int bottomY) { +void Scene52::initShipCannon(int bottomY) { _s52_shipCannonFired = false; - _s52_shipCannonWidth = MAX(_gameSys->getSpriteWidthById(14), _gameSys->getSpriteWidthById(16)); - _s52_shipCannonHeight = MAX(_gameSys->getSpriteHeightById(14), _gameSys->getSpriteHeightById(16)); + _s52_shipCannonWidth = MAX(_vm->_gameSys->getSpriteWidthById(14), _vm->_gameSys->getSpriteWidthById(16)); + _s52_shipCannonHeight = MAX(_vm->_gameSys->getSpriteHeightById(14), _vm->_gameSys->getSpriteHeightById(16)); _s52_shipCannonTopY = bottomY - _s52_shipCannonHeight; _s52_shipCannonFiring = false; } -void GnapEngine::scene52_initAlienCannons() { +void Scene52::initAlienCannons() { for (int i = 0; i < 3; ++i) { _s52_alienCannonIds[i] = 0; _s52_alienCannonFired[i] = 0; @@ -161,117 +168,112 @@ void GnapEngine::scene52_initAlienCannons() { _s52_alienCannonSequenceIds[2] = 32; } -void GnapEngine::scene52_fireShipCannon(int posX) { - - if (_timers[1]) +void Scene52::fireShipCannon(int posX) { + if (_vm->_timers[1]) return; - int cannonNum = scene52_getFreeShipCannon(); + int cannonNum = getFreeShipCannon(); if (cannonNum != -1) { _s52_shipCannonPosX = _s52_shipMidX / 2 + posX - _s52_shipCannonWidth / 2; _s52_shipCannonPosY = _s52_shipCannonTopY; - _gameSys->setAnimation(0x23, cannonNum + 256, cannonNum + 8); - _gameSys->insertSequence(0x23, cannonNum + 256, 0, 0, kSeqNone, 0, _s52_shipCannonPosX, _s52_shipCannonPosY); - playSound(0x2D, false); - if (scene52_shipCannonHitShield(cannonNum)) { - _gameSys->setAnimation(0, 0, cannonNum + 8); - _gameSys->removeSequence(0x23, cannonNum + 256, true); + _vm->_gameSys->setAnimation(0x23, cannonNum + 256, cannonNum + 8); + _vm->_gameSys->insertSequence(0x23, cannonNum + 256, 0, 0, kSeqNone, 0, _s52_shipCannonPosX, _s52_shipCannonPosY); + _vm->playSound(0x2D, false); + if (shipCannonHitShield(cannonNum)) { + _vm->_gameSys->setAnimation(0, 0, cannonNum + 8); + _vm->_gameSys->removeSequence(0x23, cannonNum + 256, true); } else { _s52_shipCannonFired = true; _s52_shipCannonPosY -= 13; _s52_shipCannonFiring = true; } - _timers[1] = 5; + _vm->_timers[1] = 5; } - } -void GnapEngine::scene52_fireAlienCannon() { - - if (_timers[2]) +void Scene52::fireAlienCannon() { + if (_vm->_timers[2]) return; - int cannonNum = scene52_getFreeAlienCannon(); + int cannonNum = getFreeAlienCannon(); if (cannonNum != -1) { int alienX1 = _s52_alienLeftX + _s52_alienRowXOfs[0]; int alienX2 = _s52_alienLeftX + _s52_alienRowXOfs[0] + 5 * _s52_alienWidth - (_s52_alienWidth / 2 - 15); - _s52_alienCannonPosX[cannonNum] = getRandom(alienX2 - alienX1) + alienX1; + _s52_alienCannonPosX[cannonNum] = _vm->getRandom(alienX2 - alienX1) + alienX1; _s52_alienCannonPosY[cannonNum] = 104; _s52_alienCannonFired[cannonNum] = 1; - _gameSys->setAnimation(_s52_alienCannonSequenceIds[cannonNum], _s52_alienCannonIds[cannonNum] + 256, cannonNum + 9); - _gameSys->insertSequence(_s52_alienCannonSequenceIds[cannonNum], _s52_alienCannonIds[cannonNum] + 256, 0, 0, + _vm->_gameSys->setAnimation(_s52_alienCannonSequenceIds[cannonNum], _s52_alienCannonIds[cannonNum] + 256, cannonNum + 9); + _vm->_gameSys->insertSequence(_s52_alienCannonSequenceIds[cannonNum], _s52_alienCannonIds[cannonNum] + 256, 0, 0, kSeqNone, 0, _s52_alienCannonPosX[cannonNum], _s52_alienCannonPosY[cannonNum]); _s52_alienCannonPosY[cannonNum] -= 13; - _timers[2] = 5; + _vm->_timers[2] = 5; } - } -int GnapEngine::scene52_getFreeShipCannon() { +int Scene52::getFreeShipCannon() { if (!_s52_shipCannonFired) return 0; return -1; } -int GnapEngine::scene52_getFreeAlienCannon() { +int Scene52::getFreeAlienCannon() { for (int i = 0; i < 3; ++i) if (!_s52_alienCannonFired[i]) return i; return -1; } -void GnapEngine::scene52_updateShipCannon() { - if (_s52_shipCannonFired && _gameSys->getAnimationStatus(8) == 2) { +void Scene52::updateShipCannon() { + if (_s52_shipCannonFired && _vm->_gameSys->getAnimationStatus(8) == 2) { _s52_shipCannonPosY -= 13; if (_s52_shipCannonPosY - 13 >= 135) { - if (scene52_updateHitAlien()) { - _gameSys->setAnimation(0, 0, 8); - _gameSys->removeSequence(35, 256, true); + if (updateHitAlien()) { + _vm->_gameSys->setAnimation(0, 0, 8); + _vm->_gameSys->removeSequence(35, 256, true); _s52_shipCannonFired = false; - scene52_drawScore(_s52_gameScore); + drawScore(_s52_gameScore); } else { - _gameSys->setAnimation(35, 256, 8); - _gameSys->insertSequence(35, 256, 35, 256, kSeqSyncWait, 0, _s52_shipCannonPosX, _s52_shipCannonPosY); + _vm->_gameSys->setAnimation(35, 256, 8); + _vm->_gameSys->insertSequence(35, 256, 35, 256, kSeqSyncWait, 0, _s52_shipCannonPosX, _s52_shipCannonPosY); _s52_shipCannonPosY -= 13; } } else { - _gameSys->setAnimation(0, 0, 8); - _gameSys->removeSequence(35, 256, true); + _vm->_gameSys->setAnimation(0, 0, 8); + _vm->_gameSys->removeSequence(35, 256, true); _s52_shipCannonFired = false; } } } -void GnapEngine::scene52_updateAlienCannons() { +void Scene52::updateAlienCannons() { for (int i = 0; i < 3; ++i) { - if (_s52_alienCannonFired[i] && _gameSys->getAnimationStatus(i + 9) == 2) { + if (_s52_alienCannonFired[i] && _vm->_gameSys->getAnimationStatus(i + 9) == 2) { _s52_alienCannonPosY[i] += 13; if (_s52_shipCannonHeight + _s52_alienCannonPosY[i] + 13 <= 550) { - if (scene52_alienCannonHitShip(i)) { - _gameSys->setAnimation(0, 0, i + 9); + if (alienCannonHitShip(i)) { + _vm->_gameSys->setAnimation(0, 0, i + 9); _s52_alienCannonFired[i] = 0; - scene52_shipExplode(); - } else if (scene52_alienCannonHitShield(i)) { + shipExplode(); + } else if (alienCannonHitShield(i)) { _s52_alienCannonFired[i] = 0; } else { - _gameSys->insertSequence(_s52_alienCannonSequenceIds[i], 1 - _s52_alienCannonIds[i] + 256, 0, 0, + _vm->_gameSys->insertSequence(_s52_alienCannonSequenceIds[i], 1 - _s52_alienCannonIds[i] + 256, 0, 0, kSeqNone, 0, _s52_alienCannonPosX[i], _s52_alienCannonPosY[i]); - _gameSys->setAnimation(_s52_alienCannonSequenceIds[i], 1 - _s52_alienCannonIds[i] + 256, i + 9); + _vm->_gameSys->setAnimation(_s52_alienCannonSequenceIds[i], 1 - _s52_alienCannonIds[i] + 256, i + 9); _s52_alienCannonIds[i] = 1 - _s52_alienCannonIds[i]; _s52_alienCannonPosY[i] += 13; } } else { - _gameSys->setAnimation(0, 0, i + 9); + _vm->_gameSys->setAnimation(0, 0, i + 9); _s52_alienCannonFired[i] = 0; } } } } -void GnapEngine::scene52_initAliens() { - +void Scene52::initAliens() { if (!_s52_aliensInitialized) { - scene52_initAlienSize(); + initAlienSize(); _s52_aliensInitialized = true; } @@ -282,91 +284,88 @@ void GnapEngine::scene52_initAliens() { _s52_alienSingle = false; _s52_alienRowDownCtr = 0; - scene52_initShields(); + initShields(); _s52_alienRowKind[0] = -1; _s52_alienRowKind[1] = -1; _s52_alienRowKind[2] = -1; _s52_alienRowKind[3] = -1; - _s52_alienRowKind[4] = getRandom(2) != 0 ? 24 : 27; - _s52_alienRowKind[5] = getRandom(2) != 0 ? 25 : 28; - _s52_alienRowKind[6] = getRandom(2) != 0 ? 26 : 29; + _s52_alienRowKind[4] = _vm->getRandom(2) != 0 ? 24 : 27; + _s52_alienRowKind[5] = _vm->getRandom(2) != 0 ? 25 : 28; + _s52_alienRowKind[6] = _vm->getRandom(2) != 0 ? 26 : 29; for (int i = 0; i < 7; ++i) { _s52_alienRowAnims[i] = i; _s52_alienRowXOfs[i] = 0; - scene52_initAlienRowKind(i, _s52_alienRowKind[i]); - scene52_insertAlienRow(i); + initAlienRowKind(i, _s52_alienRowKind[i]); + insertAlienRow(i); } - } -void GnapEngine::scene52_initAlienRowKind(int rowNum, int alienKind) { +void Scene52::initAlienRowKind(int rowNum, int alienKind) { for (int i = 0; i < 5; ++i) _s52_items[rowNum][i] = alienKind; } -void GnapEngine::scene52_insertAlienRow(int rowNum) { +void Scene52::insertAlienRow(int rowNum) { if (_s52_alienRowKind[rowNum] >= 0) { - scene52_insertAlienRowAliens(rowNum); + insertAlienRowAliens(rowNum); _s52_alienRowIds[rowNum] = 256; - _gameSys->setAnimation(_s52_alienRowKind[rowNum], _s52_alienRowIds[rowNum], _s52_alienRowAnims[rowNum]); + _vm->_gameSys->setAnimation(_s52_alienRowKind[rowNum], _s52_alienRowIds[rowNum], _s52_alienRowAnims[rowNum]); ++_s52_liveAlienRows; } } -void GnapEngine::scene52_insertAlienRowAliens(int rowNum) { +void Scene52::insertAlienRowAliens(int rowNum) { int xOffs = _s52_alienLeftX; int yOffs = _s52_alienTopY - 52 * rowNum - _s52_alienHeight + 10; for (int i = 0; i < 5; ++i) { if (_s52_items[rowNum][i] >= 0) { - _gameSys->insertSequence(_s52_items[rowNum][i], i + 256, 0, 0, kSeqNone, 0, xOffs, yOffs); + _vm->_gameSys->insertSequence(_s52_items[rowNum][i], i + 256, 0, 0, kSeqNone, 0, xOffs, yOffs); ++_s52_alienSpeed; } xOffs += _s52_alienWidth; } } -void GnapEngine::scene52_updateAlienRow(int rowNum) { - - if (_s52_alienRowKind[rowNum] != -1 && !scene52_checkAlienRow(rowNum)) { - scene52_updateAlienRowXOfs(); +void Scene52::updateAlienRow(int rowNum) { + if (_s52_alienRowKind[rowNum] != -1 && !checkAlienRow(rowNum)) { + updateAlienRowXOfs(); _s52_alienRowIds[rowNum] = -1; int xOffs = _s52_alienLeftX + _s52_alienRowXOfs[rowNum]; int yOffs = _s52_alienTopY - 52 * rowNum - _s52_alienHeight + 10; for (int i = 0; i < 5; ++i) { if (_s52_items[rowNum][i] >= 0) { - _gameSys->insertSequence(_s52_items[rowNum][i], i + 256, _s52_items[rowNum][i], i + 256, kSeqSyncWait, 0, xOffs, yOffs); + _vm->_gameSys->insertSequence(_s52_items[rowNum][i], i + 256, _s52_items[rowNum][i], i + 256, kSeqSyncWait, 0, xOffs, yOffs); if (_s52_alienRowIds[rowNum] == -1) _s52_alienRowIds[rowNum] = i + 256; } else if (_s52_items[rowNum][i] == -2) { - _gameSys->removeSequence(_s52_alienRowKind[rowNum], i + 256, true); + _vm->_gameSys->removeSequence(_s52_alienRowKind[rowNum], i + 256, true); _s52_items[rowNum][i] = -1; --_s52_alienSpeed; } xOffs += _s52_alienWidth; } if (_s52_alienRowIds[rowNum] == -1) { - _gameSys->setAnimation(0, 0, _s52_alienRowAnims[rowNum]); + _vm->_gameSys->setAnimation(0, 0, _s52_alienRowAnims[rowNum]); // MessageBoxA(0, "No live aliens!", "Error 3:", 0x30u); } else { - _gameSys->setAnimation(_s52_alienRowKind[rowNum], _s52_alienRowIds[rowNum], _s52_alienRowAnims[rowNum]); + _vm->_gameSys->setAnimation(_s52_alienRowKind[rowNum], _s52_alienRowIds[rowNum], _s52_alienRowAnims[rowNum]); } if (rowNum == 1) { for (int j = 0; j < 3; ++j) { if (_s52_shieldSpriteIds[j] != -1) { - _gameSys->fillSurface(0, _s52_shieldPosX[j], _s52_arcadeScreenBottom - 44, 33, 44, 0, 0, 0); + _vm->_gameSys->fillSurface(0, _s52_shieldPosX[j], _s52_arcadeScreenBottom - 44, 33, 44, 0, 0, 0); _s52_shieldSpriteIds[j] = -1; } } } if (rowNum == 0 && _s52_bottomAlienFlag) - scene52_shipExplode(); + shipExplode(); } } -void GnapEngine::scene52_moveDownAlienRow() { - +void Scene52::moveDownAlienRow() { int v2[5], v3, v1, v0, v4; for (int i = 0; i < 5; ++i) @@ -394,14 +393,14 @@ void GnapEngine::scene52_moveDownAlienRow() { _s52_alienRowKind[6] = v0; _s52_alienRowXOfs[6] = v4; - scene52_updateAlien(6); - scene52_initAlienRowKind(6, _s52_alienRowKind[6]); - scene52_insertAlienRow(6); + updateAlien(6); + initAlienRowKind(6, _s52_alienRowKind[6]); + insertAlienRow(6); _s52_bottomAlienFlag = _s52_alienRowKind[0] > -1; } -int GnapEngine::scene52_updateHitAlien() { +int Scene52::updateHitAlien() { int result = 0, rowNum, ya; int y = _s52_shipCannonTopY - _s52_shipCannonPosY; @@ -417,12 +416,12 @@ int GnapEngine::scene52_updateHitAlien() { } if (rowNum < 7) { - int hitAlienNum = scene52_getHitAlienNum(rowNum); + int hitAlienNum = getHitAlienNum(rowNum); if (hitAlienNum != -1 && _s52_items[rowNum][hitAlienNum] >= 0) { _s52_gameScore = ((_s52_items[rowNum][hitAlienNum] - 24) % 3 + _s52_gameScore + 1) % 1000; _s52_items[rowNum][hitAlienNum] = -2; - playSound(44, false); - _gameSys->insertSequence(0x21, 266, 0, 0, + _vm->playSound(44, false); + _vm->_gameSys->insertSequence(0x21, 266, 0, 0, kSeqNone, 0, _s52_alienLeftX + hitAlienNum * _s52_alienWidth + _s52_alienRowXOfs[rowNum] - 10, ya - _s52_alienHeight); result = 1; } @@ -431,8 +430,7 @@ int GnapEngine::scene52_updateHitAlien() { return result; } -int GnapEngine::scene52_getHitAlienNum(int rowNum) { - +int Scene52::getHitAlienNum(int rowNum) { int result = -1; int v3 = _s52_alienLeftX + _s52_alienRowXOfs[rowNum]; @@ -473,7 +471,7 @@ int GnapEngine::scene52_getHitAlienNum(int rowNum) { return result; } -int GnapEngine::scene52_alienCannonHitShip(int cannonNum) { +int Scene52::alienCannonHitShip(int cannonNum) { int result = 0; if (_s52_aliensCount) { @@ -496,7 +494,7 @@ int GnapEngine::scene52_alienCannonHitShip(int cannonNum) { return result; } -int GnapEngine::scene52_alienCannonHitShield(int cannonNum) { +int Scene52::alienCannonHitShield(int cannonNum) { int result = 0; int v3 = _s52_alienCannonPosY[cannonNum] + 39; @@ -533,21 +531,21 @@ int GnapEngine::scene52_alienCannonHitShield(int cannonNum) { } else { ++_s52_shieldSpriteIds[shieldNum]; if (_s52_shieldSpriteIds[shieldNum] <= 21) { - _gameSys->drawSpriteToBackground(_s52_shieldPosX[shieldNum], _s52_arcadeScreenBottom - 44, _s52_shieldSpriteIds[shieldNum]); + _vm->_gameSys->drawSpriteToBackground(_s52_shieldPosX[shieldNum], _s52_arcadeScreenBottom - 44, _s52_shieldSpriteIds[shieldNum]); } else { - _gameSys->fillSurface(0, _s52_shieldPosX[shieldNum], _s52_arcadeScreenBottom - 44, 33, 44, 0, 0, 0); + _vm->_gameSys->fillSurface(0, _s52_shieldPosX[shieldNum], _s52_arcadeScreenBottom - 44, 33, 44, 0, 0, 0); _s52_shieldSpriteIds[shieldNum] = -1; } - _gameSys->setAnimation(0, 0, cannonNum + 9); - _gameSys->insertSequence(0x21, shieldNum + 257, 0, 0, kSeqNone, 0, _s52_alienCannonPosX[cannonNum] - 18, _s52_arcadeScreenBottom - 44); - playSound(0x2C, false); + _vm->_gameSys->setAnimation(0, 0, cannonNum + 9); + _vm->_gameSys->insertSequence(0x21, shieldNum + 257, 0, 0, kSeqNone, 0, _s52_alienCannonPosX[cannonNum] - 18, _s52_arcadeScreenBottom - 44); + _vm->playSound(0x2C, false); result = 1; } return result; } -bool GnapEngine::scene52_shipCannonHitShield(int cannonNum) { +bool Scene52::shipCannonHitShield(int cannonNum) { bool result = false; if (_s52_shipCannonPosX < _s52_shieldPosX[0]) @@ -577,23 +575,23 @@ bool GnapEngine::scene52_shipCannonHitShield(int cannonNum) { } else { ++_s52_shieldSpriteIds[shieldNum]; if (_s52_shieldSpriteIds[shieldNum] <= 21) { - _gameSys->drawSpriteToBackground(_s52_shieldPosX[shieldNum], _s52_arcadeScreenBottom - 44, _s52_shieldSpriteIds[shieldNum]); + _vm->_gameSys->drawSpriteToBackground(_s52_shieldPosX[shieldNum], _s52_arcadeScreenBottom - 44, _s52_shieldSpriteIds[shieldNum]); } else { - _gameSys->fillSurface(0, _s52_shieldPosX[shieldNum], _s52_arcadeScreenBottom - 44, 33, 44, 0, 0, 0); + _vm->_gameSys->fillSurface(0, _s52_shieldPosX[shieldNum], _s52_arcadeScreenBottom - 44, 33, 44, 0, 0, 0); _s52_shieldSpriteIds[shieldNum] = -1; } - _gameSys->insertSequence(0x21, shieldNum + 257, 0, 0, kSeqNone, 0, _s52_shipCannonPosX - 18, _s52_arcadeScreenBottom - 44); - playSound(0x2C, false); + _vm->_gameSys->insertSequence(0x21, shieldNum + 257, 0, 0, kSeqNone, 0, _s52_shipCannonPosX - 18, _s52_arcadeScreenBottom - 44); + _vm->playSound(0x2C, false); result = true; } return result; } -bool GnapEngine::scene52_shipCannonHitAlien() { +bool Scene52::shipCannonHitAlien() { bool result = false; - if (_s52_aliensCount || scene52_checkAlienRow(0)) + if (_s52_aliensCount || checkAlienRow(0)) return false; int alienNextX = _s52_alienLeftX + _s52_alienRowXOfs[0]; @@ -632,18 +630,18 @@ bool GnapEngine::scene52_shipCannonHitAlien() { return result; } -void GnapEngine::scene52_shipExplode() { +void Scene52::shipExplode() { if (!_s52_aliensCount) { - _gameSys->setAnimation(0, 0, 7); - _gameSys->removeSequence(_s52_ufoSequenceId, 256, true); - playSound(44, false); - _gameSys->insertSequence(0x21, 266, 0, 0, kSeqNone, 0, _s52_shipPosX, _s52_arcadeScreenBottom); + _vm->_gameSys->setAnimation(0, 0, 7); + _vm->_gameSys->removeSequence(_s52_ufoSequenceId, 256, true); + _vm->playSound(44, false); + _vm->_gameSys->insertSequence(0x21, 266, 0, 0, kSeqNone, 0, _s52_shipPosX, _s52_arcadeScreenBottom); _s52_aliensCount = 1; - playSound(0x31, false); + _vm->playSound(0x31, false); } } -bool GnapEngine::scene52_checkAlienRow(int rowNum) { +bool Scene52::checkAlienRow(int rowNum) { for (int i = 0; i < 5; ++i) { if (_s52_items[rowNum][i] >= 0) return false; @@ -652,14 +650,14 @@ bool GnapEngine::scene52_checkAlienRow(int rowNum) { bool found = false; for (int j = 0; j < 5; ++j) if (_s52_items[rowNum][j] == -2) { - _gameSys->removeSequence(_s52_alienRowKind[rowNum], j + 256, true); + _vm->_gameSys->removeSequence(_s52_alienRowKind[rowNum], j + 256, true); _s52_items[rowNum][j] = -1; --_s52_alienSpeed; found = true; } if (found) { - _gameSys->setAnimation(0, 0, _s52_alienRowAnims[rowNum]); + _vm->_gameSys->setAnimation(0, 0, _s52_alienRowAnims[rowNum]); --_s52_liveAlienRows; } @@ -669,8 +667,7 @@ bool GnapEngine::scene52_checkAlienRow(int rowNum) { return true; } -void GnapEngine::scene52_updateAlienRowXOfs() { - +void Scene52::updateAlienRowXOfs() { int amount = 2 * (3 - _s52_liveAlienRows) + 1; if (_s52_alienSpeed == 2) @@ -699,110 +696,109 @@ void GnapEngine::scene52_updateAlienRowXOfs() { } } -void GnapEngine::scene52_initAlienSize() { - _s52_alienWidth = _gameSys->getSpriteWidthById(0); - if (_gameSys->getSpriteWidthById(1) > _s52_alienWidth) - _s52_alienWidth = _gameSys->getSpriteWidthById(1); - if (_gameSys->getSpriteWidthById(4) > _s52_alienWidth) - _s52_alienWidth = _gameSys->getSpriteWidthById(4); - if (_gameSys->getSpriteWidthById(5) > _s52_alienWidth) - _s52_alienWidth = _gameSys->getSpriteWidthById(5); - if (_gameSys->getSpriteWidthById(12) > _s52_alienWidth) - _s52_alienWidth = _gameSys->getSpriteWidthById(12); - if (_gameSys->getSpriteWidthById(13) > _s52_alienWidth) - _s52_alienWidth = _gameSys->getSpriteWidthById(13); - - _s52_alienHeight = _gameSys->getSpriteHeightById(0); - if (_gameSys->getSpriteHeightById(1) > _s52_alienHeight) - _s52_alienHeight = _gameSys->getSpriteHeightById(1); - if (_gameSys->getSpriteHeightById(4) > _s52_alienHeight) - _s52_alienHeight = _gameSys->getSpriteHeightById(4); - if (_gameSys->getSpriteHeightById(5) > _s52_alienHeight) - _s52_alienHeight = _gameSys->getSpriteHeightById(5); - if (_gameSys->getSpriteHeightById(12) > _s52_alienHeight) - _s52_alienHeight = _gameSys->getSpriteHeightById(12); - if (_gameSys->getSpriteHeightById(13) > _s52_alienHeight) - _s52_alienHeight = _gameSys->getSpriteHeightById(13); +void Scene52::initAlienSize() { + _s52_alienWidth = _vm->_gameSys->getSpriteWidthById(0); + if (_vm->_gameSys->getSpriteWidthById(1) > _s52_alienWidth) + _s52_alienWidth = _vm->_gameSys->getSpriteWidthById(1); + if (_vm->_gameSys->getSpriteWidthById(4) > _s52_alienWidth) + _s52_alienWidth = _vm->_gameSys->getSpriteWidthById(4); + if (_vm->_gameSys->getSpriteWidthById(5) > _s52_alienWidth) + _s52_alienWidth = _vm->_gameSys->getSpriteWidthById(5); + if (_vm->_gameSys->getSpriteWidthById(12) > _s52_alienWidth) + _s52_alienWidth = _vm->_gameSys->getSpriteWidthById(12); + if (_vm->_gameSys->getSpriteWidthById(13) > _s52_alienWidth) + _s52_alienWidth = _vm->_gameSys->getSpriteWidthById(13); + + _s52_alienHeight = _vm->_gameSys->getSpriteHeightById(0); + if (_vm->_gameSys->getSpriteHeightById(1) > _s52_alienHeight) + _s52_alienHeight = _vm->_gameSys->getSpriteHeightById(1); + if (_vm->_gameSys->getSpriteHeightById(4) > _s52_alienHeight) + _s52_alienHeight = _vm->_gameSys->getSpriteHeightById(4); + if (_vm->_gameSys->getSpriteHeightById(5) > _s52_alienHeight) + _s52_alienHeight = _vm->_gameSys->getSpriteHeightById(5); + if (_vm->_gameSys->getSpriteHeightById(12) > _s52_alienHeight) + _s52_alienHeight = _vm->_gameSys->getSpriteHeightById(12); + if (_vm->_gameSys->getSpriteHeightById(13) > _s52_alienHeight) + _s52_alienHeight = _vm->_gameSys->getSpriteHeightById(13); _s52_alienTopY = _s52_shipCannonTopY + 52; _s52_alienLeftX = (800 - 5 * _s52_alienWidth) / 2; - } -void GnapEngine::scene52_playSound() { +void Scene52::playSound() { if (_s52_soundToggle) { - playSound(0x2F, false); + _vm->playSound(0x2F, false); _s52_soundToggle = false; } else { - playSound(0x2E, false); + _vm->playSound(0x2E, false); _s52_soundToggle = true; } } -void GnapEngine::scene52_updateAliens() { +void Scene52::updateAliens() { for (int i = 0; i < 7; ++i) - scene52_updateAlien(i); + updateAlien(i); } -void GnapEngine::scene52_updateAlien(int rowNum) { - if (_s52_alienRowKind[rowNum] >= 0 && !scene52_checkAlienRow(rowNum)) { +void Scene52::updateAlien(int rowNum) { + if (_s52_alienRowKind[rowNum] >= 0 && !checkAlienRow(rowNum)) { for (int i = 0; i < 5; ++i) { if (_s52_items[rowNum][i] >= 0) _s52_items[rowNum][i] = -2; } - scene52_checkAlienRow(rowNum); + checkAlienRow(rowNum); } } -void GnapEngine::scene52_loseShip() { +void Scene52::loseShip() { --_s52_shipsLeft; if (_s52_shipsLeft == 2) { - _gameSys->fillSurface(0, 120, 140, _s52_shipMidX, _s52_shipMidY, 0, 0, 0); + _vm->_gameSys->fillSurface(0, 120, 140, _s52_shipMidX, _s52_shipMidY, 0, 0, 0); } else if (_s52_shipsLeft == 1) { - _gameSys->fillSurface(0, 120, 185, _s52_shipMidX, _s52_shipMidY, 0, 0, 0); + _vm->_gameSys->fillSurface(0, 120, 185, _s52_shipMidX, _s52_shipMidY, 0, 0, 0); } } -void GnapEngine::scene52_initShields() { +void Scene52::initShields() { for (int i = 0; i < 3; ++i) { - _gameSys->drawSpriteToBackground(_s52_shieldPosX[i], _s52_arcadeScreenBottom - 44, 17); + _vm->_gameSys->drawSpriteToBackground(_s52_shieldPosX[i], _s52_arcadeScreenBottom - 44, 17); _s52_shieldSpriteIds[i] = 17; } } -void GnapEngine::scene52_initAnims() { +void Scene52::initAnims() { for (int i = 0; i < 7; ++i) - _gameSys->setAnimation(0, 0, i); - _gameSys->setAnimation(0, 0, 7); + _vm->_gameSys->setAnimation(0, 0, i); + _vm->_gameSys->setAnimation(0, 0, 7); for (int j = 0; j < 1; ++j) - _gameSys->setAnimation(0, 0, j + 8); + _vm->_gameSys->setAnimation(0, 0, j + 8); for (int k = 0; k < 3; ++k) - _gameSys->setAnimation(0, 0, k + 9); + _vm->_gameSys->setAnimation(0, 0, k + 9); } -void GnapEngine::scene52_drawScore(int score) { +void Scene52::drawScore(int score) { char str[4]; sprintf(str, "%03d", score); - _gameSys->fillSurface(0, 420, 80, 48, 30, 0, 0, 0); - _gameSys->drawTextToSurface(0, 420, 80, 255, 255, 255, str); + _vm->_gameSys->fillSurface(0, 420, 80, 48, 30, 0, 0, 0); + _vm->_gameSys->drawTextToSurface(0, 420, 80, 255, 255, 255, str); } -void GnapEngine::scene52_run() { - _timers[1] = 0; +void Scene52::run() { + _vm->_timers[1] = 0; - hideCursor(); + _vm->hideCursor(); // TODO loadFont("maturasc", "Matura MT Script Capitals", 2000); // TODO setFontSize(24); _s52_gameScore = 0; - _gameSys->drawTextToSurface(0, 300, 80, 255, 255, 255, "SCORE"); - _gameSys->drawTextToSurface(0, 468, 80, 255, 255, 255, "0"); + _vm->_gameSys->drawTextToSurface(0, 300, 80, 255, 255, 255, "SCORE"); + _vm->_gameSys->drawTextToSurface(0, 468, 80, 255, 255, 255, "0"); - scene52_drawScore(0); + drawScore(0); _s52_shipMidX = 33; - _s52_shipMidY = _gameSys->getSpriteHeightById(15); + _s52_shipMidY = _vm->_gameSys->getSpriteHeightById(15); _s52_shipPosX = (800 - _s52_shipMidX) / 2; _s52_arcadeScreenBottom = 496; _s52_arcadeScreenRight = 595 - _s52_shipMidX; @@ -817,82 +813,82 @@ void GnapEngine::scene52_run() { for (int i = 0; i < 3; ++i) _s52_shieldSpriteIds[i] = -1; - _gameSys->drawSpriteToBackground(120, 140, 0xF); - _gameSys->drawSpriteToBackground(120, 185, 0xF); + _vm->_gameSys->drawSpriteToBackground(120, 140, 0xF); + _vm->_gameSys->drawSpriteToBackground(120, 185, 0xF); - scene52_initShipCannon(_s52_arcadeScreenBottom); - scene52_initAlienCannons(); - scene52_initAliens(); + initShipCannon(_s52_arcadeScreenBottom); + initAlienCannons(); + initAliens(); _s52_nextUfoSequenceId = 0x22; - _gameSys->setAnimation(0x22, 256, 7); - _gameSys->insertSequence(_s52_nextUfoSequenceId, 256, 0, 0, kSeqNone, 0, _s52_shipPosX, _s52_arcadeScreenBottom); + _vm->_gameSys->setAnimation(0x22, 256, 7); + _vm->_gameSys->insertSequence(_s52_nextUfoSequenceId, 256, 0, 0, kSeqNone, 0, _s52_shipPosX, _s52_arcadeScreenBottom); _s52_ufoSequenceId = _s52_nextUfoSequenceId; - clearKeyStatus1(Common::KEYCODE_RIGHT); - clearKeyStatus1(Common::KEYCODE_LEFT); - clearKeyStatus1(Common::KEYCODE_SPACE); - clearKeyStatus1(Common::KEYCODE_UP); - clearKeyStatus1(Common::KEYCODE_ESCAPE); + _vm->clearKeyStatus1(Common::KEYCODE_RIGHT); + _vm->clearKeyStatus1(Common::KEYCODE_LEFT); + _vm->clearKeyStatus1(Common::KEYCODE_SPACE); + _vm->clearKeyStatus1(Common::KEYCODE_UP); + _vm->clearKeyStatus1(Common::KEYCODE_ESCAPE); - _timers[2] = 5; + _vm->_timers[2] = 5; _s52_shipFlag = false; - _timers[0] = 10; + _vm->_timers[0] = 10; _s52_alienWave = true; - while (!_sceneDone) { - gameUpdateTick(); + while (!_vm->_sceneDone) { + _vm->gameUpdateTick(); - while (isKeyStatus2(Common::KEYCODE_RIGHT)) { - scene52_update(); - if (_gameSys->getAnimationStatus(7) == 2) { + while (_vm->isKeyStatus2(Common::KEYCODE_RIGHT)) { + update(); + if (_vm->_gameSys->getAnimationStatus(7) == 2) { if (_s52_shipPosX < _s52_arcadeScreenRight) { _s52_shipPosX += 15; if (_s52_shipPosX > _s52_arcadeScreenRight) _s52_shipPosX = _s52_arcadeScreenRight; - _gameSys->setAnimation(_s52_nextUfoSequenceId, 256, 7); - _gameSys->insertSequence(_s52_nextUfoSequenceId, 256, _s52_ufoSequenceId, 256, kSeqSyncWait, 0, _s52_shipPosX, _s52_arcadeScreenBottom); + _vm->_gameSys->setAnimation(_s52_nextUfoSequenceId, 256, 7); + _vm->_gameSys->insertSequence(_s52_nextUfoSequenceId, 256, _s52_ufoSequenceId, 256, kSeqSyncWait, 0, _s52_shipPosX, _s52_arcadeScreenBottom); _s52_ufoSequenceId = _s52_nextUfoSequenceId; - if (_s52_bottomAlienFlag && scene52_shipCannonHitAlien()) - scene52_shipExplode(); + if (_s52_bottomAlienFlag && shipCannonHitAlien()) + shipExplode(); } break; } } - while (isKeyStatus2(Common::KEYCODE_LEFT)) { - scene52_update(); - if (_gameSys->getAnimationStatus(7) == 2) { + while (_vm->isKeyStatus2(Common::KEYCODE_LEFT)) { + update(); + if (_vm->_gameSys->getAnimationStatus(7) == 2) { if (_s52_shipPosX > _s52_arcadeScreenLeft) { _s52_shipPosX -= 15; if (_s52_shipPosX < _s52_arcadeScreenLeft) _s52_shipPosX = _s52_arcadeScreenLeft; - _gameSys->setAnimation(_s52_nextUfoSequenceId, 256, 7); - _gameSys->insertSequence(_s52_nextUfoSequenceId, 256, _s52_ufoSequenceId, 256, kSeqSyncWait, 0, _s52_shipPosX, _s52_arcadeScreenBottom); + _vm->_gameSys->setAnimation(_s52_nextUfoSequenceId, 256, 7); + _vm->_gameSys->insertSequence(_s52_nextUfoSequenceId, 256, _s52_ufoSequenceId, 256, kSeqSyncWait, 0, _s52_shipPosX, _s52_arcadeScreenBottom); _s52_ufoSequenceId = _s52_nextUfoSequenceId; - if (_s52_bottomAlienFlag && scene52_shipCannonHitAlien()) - scene52_shipExplode(); + if (_s52_bottomAlienFlag && shipCannonHitAlien()) + shipExplode(); } break; } } - scene52_update(); + update(); - if (sceneXX_sub_4466B1()) { + if (_vm->sceneXX_sub_4466B1()) { _s52_alienWave = false; - _gameSys->waitForUpdate(); - scene52_initAnims(); - clearKeyStatus1(30); - _sceneDone = true; + _vm->_gameSys->waitForUpdate(); + initAnims(); + _vm->clearKeyStatus1(30); + _vm->_sceneDone = true; } } // TODO freeFont(); - _gameSys->waitForUpdate(); + _vm->_gameSys->waitForUpdate(); } } // End of namespace Gnap diff --git a/engines/gnap/scenes/scene52.h b/engines/gnap/scenes/scene52.h new file mode 100644 index 0000000000..0fbc29cb71 --- /dev/null +++ b/engines/gnap/scenes/scene52.h @@ -0,0 +1,118 @@ +/* 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_SCENE52_H +#define GNAP_SCENE52_H + +#include "gnap/debugger.h" +#include "gnap/scenes/scenecore.h" + +namespace Gnap { + +class GnapEngine; + +class Scene52: public Scene { +public: + Scene52(GnapEngine *vm); + ~Scene52() {} + + virtual int init(); + virtual void updateHotspots(); + virtual void run(); + virtual void updateAnimations() {}; + virtual void updateAnimationsCb() {}; + +private: + int _s52_liveAlienRows; + int _s52_gameScore; + bool _s52_soundToggle; + int _s52_arcadeScreenLeft; + int _s52_arcadeScreenRight; + int _s52_arcadeScreenBottom; + int _s52_shipsLeft; + int _s52_shieldSpriteIds[3]; + int _s52_shieldPosX[3]; + int _s52_shipPosX; + int _s52_shipCannonPosX, _s52_shipCannonPosY; + bool _s52_shipCannonFiring; + bool _s52_shipCannonFired; + int _s52_shipCannonWidth, _s52_shipCannonHeight; + int _s52_shipCannonTopY; + int _s52_shipMidX, _s52_shipMidY; + bool _s52_shipFlag; + bool _s52_aliensInitialized; + int _s52_alienSpeed, _s52_alienDirection; + int _s52_alienWidth, _s52_alienHeight; + int _s52_alienLeftX, _s52_alienTopY; + int _s52_alienRowDownCtr; + int _s52_alienRowKind[7]; + int _s52_alienRowAnims[7]; + int _s52_alienRowIds[7]; + int _s52_alienRowXOfs[7]; + int _s52_alienCannonFired[3]; + int _s52_alienCannonPosX[3]; + int _s52_alienCannonPosY[3]; + int _s52_alienCannonSequenceIds[3]; + int _s52_alienCannonIds[3]; + bool _s52_alienWave, _s52_alienSingle; + int _s52_alienCounter; + bool _s52_bottomAlienFlag; + int _s52_aliensCount; + int _s52_items[8][5]; + int _s52_nextUfoSequenceId, _s52_ufoSequenceId; + + void update(); + void initShipCannon(int bottomY); + void initAlienCannons(); + void fireShipCannon(int posX); + void fireAlienCannon(); + int getFreeShipCannon(); + int getFreeAlienCannon(); + void updateShipCannon(); + void updateAlienCannons(); + void initAliens(); + void initAlienRowKind(int rowNum, int alienKind); + void insertAlienRow(int rowNum); + void insertAlienRowAliens(int rowNum); + void updateAlienRow(int rowNum); + void moveDownAlienRow(); + int updateHitAlien(); + int getHitAlienNum(int rowNum); + int alienCannonHitShip(int cannonNum); + int alienCannonHitShield(int cannonNum); + bool shipCannonHitShield(int cannonNum); + bool shipCannonHitAlien(); + void shipExplode(); + bool checkAlienRow(int rowNum); + void updateAlienRowXOfs(); + void initAlienSize(); + void playSound(); + void updateAliens(); + void updateAlien(int rowNum); + void loseShip(); + void initShields(); + void initAnims(); + void drawScore(int score); +}; + +} // End of namespace Gnap +#endif // GNAP_SCENE52_H diff --git a/engines/gnap/scenes/scenecore.cpp b/engines/gnap/scenes/scenecore.cpp index 438604670b..f9f4af91ab 100644 --- a/engines/gnap/scenes/scenecore.cpp +++ b/engines/gnap/scenes/scenecore.cpp @@ -72,6 +72,8 @@ #include "gnap/scenes/scene48.h" #include "gnap/scenes/scene49.h" #include "gnap/scenes/scene50.h" +#include "gnap/scenes/scene51.h" +#include "gnap/scenes/scene52.h" #include "gnap/scenes/scene54.h" namespace Gnap { @@ -419,12 +421,14 @@ int GnapEngine::initSceneLogic() { initSceneGrid(21, 146, 11, 10); break; case 51: - backgroundId = scene51_init(); + _scene = new Scene51(this); + backgroundId = _scene->init(); _gameSys->setScaleValues(0, 500, 1, 1000); initSceneGrid(21, 146, 11, 10); break; case 52: - backgroundId = scene52_init(); + _scene = new Scene52(this); + backgroundId = _scene->init(); _gameSys->setScaleValues(0, 500, 1, 1000); initSceneGrid(21, 146, 11, 10); break; @@ -783,10 +787,12 @@ void GnapEngine::runSceneLogic() { _newSceneNum = _prevSceneNum; break; case 51: - scene51_run(); + _scene->run(); + delete _scene; break; case 52: - scene52_run(); + _scene->run(); + delete _scene; _newSceneNum = _prevSceneNum; break; case 53: |