From f42f29d8f8e1cc39b02cf1827318ff8fb59d3dd7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 8 Sep 2013 11:30:23 +0200 Subject: AVALANCHE: Rename Timeout into Timer --- engines/avalanche/acci2.cpp | 30 +- engines/avalanche/animation.cpp | 20 +- engines/avalanche/animation.h | 2 +- engines/avalanche/avalanche.cpp | 10 +- engines/avalanche/avalanche.h | 4 +- engines/avalanche/avalot.cpp | 4 +- engines/avalanche/enid2.cpp | 2 +- engines/avalanche/lucerna2.cpp | 30 +- engines/avalanche/module.mk | 2 +- engines/avalanche/scrolls2.cpp | 4 +- engines/avalanche/sequence2.cpp | 6 +- engines/avalanche/sequence2.h | 2 +- engines/avalanche/timeout2.cpp | 684 ---------------------------------------- engines/avalanche/timeout2.h | 180 ----------- engines/avalanche/timer.cpp | 684 ++++++++++++++++++++++++++++++++++++++++ engines/avalanche/timer.h | 180 +++++++++++ 16 files changed, 922 insertions(+), 922 deletions(-) delete mode 100644 engines/avalanche/timeout2.cpp delete mode 100644 engines/avalanche/timeout2.h create mode 100644 engines/avalanche/timer.cpp create mode 100644 engines/avalanche/timer.h (limited to 'engines/avalanche') diff --git a/engines/avalanche/acci2.cpp b/engines/avalanche/acci2.cpp index 3691ae9afc..fe7296782d 100644 --- a/engines/avalanche/acci2.cpp +++ b/engines/avalanche/acci2.cpp @@ -34,7 +34,7 @@ #include "avalanche/lucerna2.h" #include "avalanche/scrolls2.h" #include "avalanche/visa2.h" -#include "avalanche/timeout2.h" +#include "avalanche/timer.h" #include "avalanche/animation.h" #include "avalanche/enid2.h" #include "avalanche/celer2.h" @@ -379,7 +379,7 @@ void Acci::storeInterrogation(byte interrogation) { while ((_vm->_parser->_inputText.lastChar() == ' ') && (!_vm->_parser->_inputText.empty())) _vm->_parser->_inputText.deleteLastChar(); - _vm->_timeout->loseTimer(_vm->_timeout->kReasonCardiffsurvey); // If you want to use any other timer, put this into the case statement. + _vm->_timer->loseTimer(_vm->_timer->kReasonCardiffsurvey); // If you want to use any other timer, put this into the case statement. switch (interrogation) { case 1: @@ -419,7 +419,7 @@ void Acci::storeInterrogation(byte interrogation) { } if (interrogation < 4) - _vm->_timeout->cardiffSurvey(); + _vm->_timer->cardiffSurvey(); } @@ -1041,7 +1041,7 @@ void Acci::notInOrder() { void Acci::goToCauldron() { _vm->_animation->tr[1]._callEachStepFl = false; // Stops Geida_Procs. - _vm->_timeout->addTimer(1, _vm->_timeout->kProcSpludwickGoesToCauldron, _vm->_timeout->kReasonSpludWalk); + _vm->_timer->addTimer(1, _vm->_timer->kProcSpludwickGoesToCauldron, _vm->_timer->kReasonSpludWalk); _vm->_animation->tr[1].walkto(2); } @@ -1143,7 +1143,7 @@ void Acci::standUp() { _vm->_celer->drawBackgroundSprite(-1, -1, 4); // Picture of empty pillow. _vm->_lucerna->incScore(1); _vm->_gyro->_dna._avvyInBed = false; - _vm->_timeout->loseTimer(_vm->_timeout->kReasonArkataShouts); + _vm->_timer->loseTimer(_vm->_timer->kReasonArkataShouts); } else already(); break; @@ -1242,7 +1242,7 @@ void Acci::giveGeidaTheLute() { _vm->_lucerna->refreshObjectList(); _vm->_visa->displayScrollChain('q', 64); // She plays it. - _vm->_timeout->addTimer(1, _vm->_timeout->kProcGiveLuteToGeida, _vm->_timeout->kReasonGeidaSings); + _vm->_timer->addTimer(1, _vm->_timer->kProcGiveLuteToGeida, _vm->_timer->kReasonGeidaSings); _vm->_enid->backToBootstrap(4); } @@ -1259,7 +1259,7 @@ void Acci::winSequence() { _vm->_sequence->thenShow(8); _vm->_sequence->thenShow(9); _vm->_sequence->startToClose(); - _vm->_timeout->addTimer(30, _vm->_timeout->kProcWinning, _vm->_timeout->kReasonWinning); + _vm->_timer->addTimer(30, _vm->_timer->kProcWinning, _vm->_timer->kReasonWinning); } void Acci::personSpeaks() { @@ -1506,7 +1506,7 @@ void Acci::doThat() { case kVerbCodeQuit: // quit if (_vm->_gyro->kDemo) { warning("STUB: Acci::doThat() - case kVerbCodequit"); - // _vm->_visa->dixi('pos', 31); + // _vm->_visa->displayScrollChain('pos', 31); // close(demofile); // exit(0); // Change this later!!! } @@ -1682,7 +1682,7 @@ void Acci::doThat() { case kVerbCodePee: if (_vm->_gyro->setFlag('P')) { _vm->_scrolls->displayText("Hmm, I don't think anyone will notice..."); - _vm->_timeout->addTimer(4, _vm->_timeout->kProcUrinate, _vm->_timeout->kReasonGoToToilet); + _vm->_timer->addTimer(4, _vm->_timer->kProcUrinate, _vm->_timer->kReasonGoToToilet); } else _vm->_scrolls->displayText(Common::String("It would be ") + _vm->_scrolls->kControlItalic + "VERY" + _vm->_scrolls->kControlRoman + " unwise to do that here, Avvy!"); @@ -1706,7 +1706,7 @@ void Acci::doThat() { _vm->_animation->tr[1]._callEachStepFl = true; _vm->_animation->tr[1]._eachStepProc = _vm->_animation->kProcBackAndForth; _vm->_gyro->_dna._avariciusTalk = 14; - _vm->_timeout->addTimer(177, _vm->_timeout->kProcAvariciusTalks, _vm->_timeout->kReasonAvariciusTalks); + _vm->_timer->addTimer(177, _vm->_timer->kProcAvariciusTalks, _vm->_timer->kReasonAvariciusTalks); } } else _vm->_scrolls->displayText("Nothing appears to happen..."); @@ -1769,7 +1769,7 @@ void Acci::doThat() { _vm->_celer->drawBackgroundSprite(-1, -1, 10); _vm->_gyro->_dna._malagauche = 177; - _vm->_timeout->addTimer(27, _vm->_timeout->kProcBuyDrinks, _vm->_timeout->kReasonDrinks); + _vm->_timer->addTimer(27, _vm->_timer->kProcBuyDrinks, _vm->_timer->kReasonDrinks); break; case 52: examine(); @@ -1795,7 +1795,7 @@ void Acci::doThat() { _vm->_celer->drawBackgroundSprite(-1, -1, 10); _vm->_gyro->_dna._malagauche = 177; - _vm->_timeout->addTimer(27, _vm->_timeout->kProcBuyWine, _vm->_timeout->kReasonDrinks); + _vm->_timer->addTimer(27, _vm->_timer->kProcBuyWine, _vm->_timer->kReasonDrinks); } break; } @@ -1892,7 +1892,7 @@ void Acci::doThat() { else { _vm->_lucerna->incScore(4); _vm->_scrolls->displayText("The drawbridge opens!"); - _vm->_timeout->addTimer(7, _vm->_timeout->kProcOpenDrawbridge, _vm->_timeout->kReasonDrawbridgeFalls); + _vm->_timer->addTimer(7, _vm->_timer->kProcOpenDrawbridge, _vm->_timer->kReasonDrawbridgeFalls); _vm->_gyro->_dna._drawbridgeOpen = 1; } } else @@ -1944,7 +1944,7 @@ void Acci::doThat() { _vm->_scrolls->displayText("Not with your head for heights, Avvy!"); break; case kVerbCodeJump: - _vm->_timeout->addTimer(1, _vm->_timeout->kProcJump, _vm->_timeout->kReasonJumping); + _vm->_timer->addTimer(1, _vm->_timer->kProcJump, _vm->_timer->kReasonJumping); _vm->_gyro->_dna._userMovesAvvy = false; break; case kVerbCodeHiscores: @@ -1985,7 +1985,7 @@ void Acci::doThat() { _vm->_scrolls->displayText("You're already sitting!"); else { _vm->_animation->tr[0].walkto(4); // Move Avvy to the place, and sit him down. - _vm->_timeout->addTimer(1, _vm->_timeout->kProcAvvySitDown, _vm->_timeout->kReasonSittingDown); + _vm->_timer->addTimer(1, _vm->_timer->kProcAvvySitDown, _vm->_timer->kReasonSittingDown); } } else { // Default doodah. _vm->_lucerna->dusk(); diff --git a/engines/avalanche/animation.cpp b/engines/avalanche/animation.cpp index 68266f366d..df8724feb5 100644 --- a/engines/avalanche/animation.cpp +++ b/engines/avalanche/animation.cpp @@ -36,7 +36,7 @@ #include "avalanche/gyro2.h" #include "avalanche/celer2.h" #include "avalanche/sequence2.h" -#include "avalanche/timeout2.h" +#include "avalanche/timer.h" #include "avalanche/enid2.h" #include "common/scummsys.h" @@ -834,7 +834,7 @@ void Animation::catamove(byte ped) { // This proc gets called whenever you touch a line defined as _vm->_gyro->special. void Animation::dawndelay() { - _vm->_timeout->addTimer(2, _vm->_timeout->kProcDawnDelay, _vm->_timeout->kReasonDawndelay); + _vm->_timer->addTimer(2, _vm->_timer->kProcDawnDelay, _vm->_timer->kReasonDawndelay); } void Animation::call_special(uint16 which) { @@ -843,7 +843,7 @@ void Animation::call_special(uint16 which) { _vm->_celer->drawBackgroundSprite(-1, -1, 1); _vm->_gyro->_dna._brummieStairs = 1; _vm->_gyro->_magics[9]._operation = _vm->_gyro->kMagicNothing; - _vm->_timeout->addTimer(10, _vm->_timeout->kProcStairs, _vm->_timeout->kReasonBrummieStairs); + _vm->_timer->addTimer(10, _vm->_timer->kProcStairs, _vm->_timer->kReasonBrummieStairs); stopWalking(); _vm->_gyro->_dna._userMovesAvvy = false; break; @@ -877,7 +877,7 @@ void Animation::call_special(uint16 which) { case 4: // This is the ghost room link. _vm->_lucerna->dusk(); tr[0].turn(kDirRight); // you'll see this after we get back from bootstrap - _vm->_timeout->addTimer(1, _vm->_timeout->kProcGhostRoomPhew, _vm->_timeout->kReasonGhostRoomPhew); + _vm->_timer->addTimer(1, _vm->_timer->kProcGhostRoomPhew, _vm->_timer->kReasonGhostRoomPhew); _vm->_enid->backToBootstrap(3); break; case 5: @@ -895,7 +895,7 @@ void Animation::call_special(uint16 which) { tr[1]._vanishIfStill = true; tr[1]._doCheck = true; // One of them must have Check_Me switched on. _vm->_gyro->_whereIs[_vm->_gyro->kPeopleFriarTuck - 150] = 177; // Not here, then. - _vm->_timeout->addTimer(364, _vm->_timeout->kProcHangAround, _vm->_timeout->kReasonHangingAround); + _vm->_timer->addTimer(364, _vm->_timer->kProcHangAround, _vm->_timer->kReasonHangingAround); } break; case 6: // _vm->_gyro->special 6: fall down oubliette. @@ -903,17 +903,17 @@ void Animation::call_special(uint16 which) { tr[0]._moveX = 3; tr[0]._moveY = 0; tr[0]._facingDir = kDirRight; - _vm->_timeout->addTimer(1, _vm->_timeout->kProcFallDownOubliette, _vm->_timeout->kReasonFallingDownOubliette); + _vm->_timer->addTimer(1, _vm->_timer->kProcFallDownOubliette, _vm->_timer->kReasonFallingDownOubliette); break; case 7: // _vm->_gyro->special 7: stop falling down oubliette. tr[0]._visible = false; _vm->_gyro->_magics[9]._operation = _vm->_gyro->kMagicNothing; stopWalking(); - _vm->_timeout->loseTimer(_vm->_timeout->kReasonFallingDownOubliette); + _vm->_timer->loseTimer(_vm->_timer->kReasonFallingDownOubliette); //_vm->_lucerna->mblit(12, 80, 38, 160, 3, 0); //_vm->_lucerna->mblit(12, 80, 38, 160, 3, 1); _vm->_scrolls->displayText("Oh dear, you seem to be down the bottom of an oubliette."); - _vm->_timeout->addTimer(200, _vm->_timeout->kProcMeetAvaroid, _vm->_timeout->kReasonMeetingAvaroid); + _vm->_timer->addTimer(200, _vm->_timer->kProcMeetAvaroid, _vm->_timer->kReasonMeetingAvaroid); break; case 8: // _vm->_gyro->special 8: leave du Lustie's room. if ((_vm->_gyro->_dna._geidaFollows) && (!_vm->_gyro->_dna._lustieIsAsleep)) { @@ -931,7 +931,7 @@ void Animation::call_special(uint16 which) { tr[1].walkto(4); // She walks to somewhere... tr[0].done(); // Lose Avvy. _vm->_gyro->_dna._userMovesAvvy = false; - _vm->_timeout->addTimer(40, _vm->_timeout->kProcRobinHoodAndGeida, _vm->_timeout->kReasonRobinHoodAndGeida); + _vm->_timer->addTimer(40, _vm->_timer->kProcRobinHoodAndGeida, _vm->_timer->kReasonRobinHoodAndGeida); break; case 10: // _vm->_gyro->special 10: transfer north in catacombs. if ((_vm->_gyro->_dna._catacombX == 4) && (_vm->_gyro->_dna._catacombY == 1)) { @@ -1217,7 +1217,7 @@ void Animation::arrow_procs(byte tripnum) { _vm->_lucerna->gameOver(); _vm->_gyro->_dna._userMovesAvvy = false; // Stop the user from moving him. - _vm->_timeout->addTimer(55, _vm->_timeout->kProcNaughtyDuke, _vm->_timeout->kReasonNaughtyDuke); + _vm->_timer->addTimer(55, _vm->_timer->kProcNaughtyDuke, _vm->_timer->kReasonNaughtyDuke); } } else { // Arrow has hit the wall! tr[tripnum].done(); // Deallocate the arrow. diff --git a/engines/avalanche/animation.h b/engines/avalanche/animation.h index 72c86a48de..b820d2d808 100644 --- a/engines/avalanche/animation.h +++ b/engines/avalanche/animation.h @@ -25,7 +25,7 @@ * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman. */ -/* Original name TRIP5 / Trippancy V - the sprite animation subsystem */ +/* Original name: TRIP5 / Trippancy V - the sprite animation subsystem */ #ifndef AVALANCHE_ANIMATION_H #define AVALANCHE_ANIMATION_H diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp index 2e7b7f3115..b28fe7fb5f 100644 --- a/engines/avalanche/avalanche.cpp +++ b/engines/avalanche/avalanche.cpp @@ -69,7 +69,7 @@ AvalancheEngine::~AvalancheEngine() { delete _enid; delete _celer; delete _sequence; - delete _timeout; + delete _timer; delete _animation; delete _acci; delete _dropdown; @@ -90,7 +90,7 @@ Common::ErrorCode AvalancheEngine::initialize() { _enid = new Enid(this); _celer = new Celer(this); _sequence = new Sequence(this); - _timeout = new Timeout(this); + _timer = new Timer(this); _animation = new Animation(this); _acci = new Acci(this); _dropdown = new Dropdown(this); @@ -335,9 +335,9 @@ void AvalancheEngine::synchronize(Common::Serializer &sz) { //blockwrite(f, times, sizeof(times)); // Timeout.times: Timers. for (byte i = 0; i < 7; i++) { - sz.syncAsSint32LE(_timeout->_times[i]._timeLeft); - sz.syncAsByte(_timeout->_times[i]._action); - sz.syncAsByte(_timeout->_times[i]._reason); + sz.syncAsSint32LE(_timer->_times[i]._timeLeft); + sz.syncAsByte(_timer->_times[i]._action); + sz.syncAsByte(_timer->_times[i]._reason); } //blockwrite(f, seq, sizeof(seq)); // Sequencer information. diff --git a/engines/avalanche/avalanche.h b/engines/avalanche/avalanche.h index 1973f9b6ff..998363a242 100644 --- a/engines/avalanche/avalanche.h +++ b/engines/avalanche/avalanche.h @@ -42,7 +42,7 @@ #include "avalanche/enid2.h" #include "avalanche/celer2.h" #include "avalanche/sequence2.h" -#include "avalanche/timeout2.h" +#include "avalanche/timer.h" #include "avalanche/animation.h" #include "avalanche/acci2.h" #include "avalanche/dropdown2.h" @@ -79,7 +79,7 @@ public: Enid *_enid; Celer *_celer; Sequence *_sequence; - Timeout *_timeout; + Timer *_timer; Animation *_animation; Acci *_acci; Dropdown *_dropdown; diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp index e0e05144c4..a4392383b1 100644 --- a/engines/avalanche/avalot.cpp +++ b/engines/avalanche/avalot.cpp @@ -38,7 +38,7 @@ #include "avalanche/scrolls2.h" #include "avalanche/dropdown2.h" #include "avalanche/pingo2.h" -#include "avalanche/timeout2.h" +#include "avalanche/timer.h" #include "avalanche/celer2.h" #include "avalanche/enid2.h" #include "avalanche/visa2.h" @@ -205,7 +205,7 @@ void Avalot::run(Common::String arg) { _vm->_celer->updateBackgroundSprites(); _vm->_animation->animLink(); _vm->_lucerna->checkClick(); - _vm->_timeout->updateTimer(); + _vm->_timer->updateTimer(); diff --git a/engines/avalanche/enid2.cpp b/engines/avalanche/enid2.cpp index c3a195ecf4..f6e22dfc59 100644 --- a/engines/avalanche/enid2.cpp +++ b/engines/avalanche/enid2.cpp @@ -33,7 +33,7 @@ #include "avalanche/scrolls2.h" #include "avalanche/lucerna2.h" #include "avalanche/animation.h" -#include "avalanche/timeout2.h" +#include "avalanche/timer.h" #include "avalanche/celer2.h" #include "avalanche/sequence2.h" diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp index 598ff63869..1cf7b3ef70 100644 --- a/engines/avalanche/lucerna2.cpp +++ b/engines/avalanche/lucerna2.cpp @@ -33,7 +33,7 @@ #include "avalanche/gyro2.h" #include "avalanche/scrolls2.h" #include "avalanche/visa2.h" -#include "avalanche/timeout2.h" +#include "avalanche/timer.h" #include "avalanche/animation.h" #include "avalanche/enid2.h" #include "avalanche/celer2.h" @@ -340,21 +340,21 @@ void Lucerna::exitRoom(byte x) { switch (x) { case r__spludwicks: - _vm->_timeout->loseTimer(_vm->_timeout->kReasonAvariciusTalks); + _vm->_timer->loseTimer(_vm->_timer->kReasonAvariciusTalks); _vm->_gyro->_dna._avariciusTalk = 0; // He doesn't HAVE to be talking for this to work. It just deletes it IF it exists. break; case r__bridge: if (_vm->_gyro->_dna._drawbridgeOpen > 0) { _vm->_gyro->_dna._drawbridgeOpen = 4; // Fully open. - _vm->_timeout->loseTimer(_vm->_timeout->kReasonDrawbridgeFalls); + _vm->_timer->loseTimer(_vm->_timer->kReasonDrawbridgeFalls); } break; case r__outsidecardiffcastle: - _vm->_timeout->loseTimer(_vm->_timeout->kReasonCardiffsurvey); + _vm->_timer->loseTimer(_vm->_timer->kReasonCardiffsurvey); break; case r__robins: - _vm->_timeout->loseTimer(_vm->_timeout->kReasonGettingTiedUp); + _vm->_timer->loseTimer(_vm->_timer->kReasonGettingTiedUp); break; } @@ -436,7 +436,7 @@ void Lucerna::enterRoom(byte room, byte ped) { if (_vm->_gyro->_dna._avvyInBed) { _vm->_celer->drawBackgroundSprite(-1, -1, 3); _vm->_graphics->refreshBackground(); - _vm->_timeout->addTimer(100, _vm->_timeout->kProcArkataShouts, _vm->_timeout->kReasonArkataShouts); + _vm->_timer->addTimer(100, _vm->_timer->kProcArkataShouts, _vm->_timer->kReasonArkataShouts); } break; @@ -464,7 +464,7 @@ void Lucerna::enterRoom(byte room, byte ped) { _vm->_animation->tr[1].init(8, false, _vm->_animation); _vm->_animation->apped(2, 2); _vm->_animation->tr[1].walkto(4); - _vm->_timeout->addTimer(20, _vm->_timeout->kProcCrapulusSpludOut, _vm->_timeout->kReasonCrapulusSaysSpludwickOut); + _vm->_timer->addTimer(20, _vm->_timer->kProcCrapulusSpludOut, _vm->_timer->kReasonCrapulusSaysSpludwickOut); _vm->_gyro->_dna._crapulusWillTell = false; } } @@ -472,7 +472,7 @@ void Lucerna::enterRoom(byte room, byte ped) { case r__outsidespludwicks: if ((_vm->_gyro->_dna._roomCount[r__outsidespludwicks] == 1) && (ped == 1)) { - _vm->_timeout->addTimer(20, _vm->_timeout->kProcBang, _vm->_timeout->kReasonExplosion); + _vm->_timer->addTimer(20, _vm->_timer->kProcBang, _vm->_timer->kReasonExplosion); _vm->_gyro->_dna._spludwickAtHome = true; } break; @@ -527,7 +527,7 @@ void Lucerna::enterRoom(byte room, byte ped) { _vm->_animation->tr[1]._vanishIfStill = true; _vm->_gyro->_dna._passedCwytalotInHerts = true; // _vm->_gyro->whereis[#157] = r__Nowhere; // can we fit this in? - _vm->_timeout->addTimer(20, _vm->_timeout->kProcCwytalotInHerts, _vm->_timeout->kReasonCwytalotInHerts); + _vm->_timer->addTimer(20, _vm->_timer->kProcCwytalotInHerts, _vm->_timer->kReasonCwytalotInHerts); } break; @@ -548,7 +548,7 @@ void Lucerna::enterRoom(byte room, byte ped) { _vm->_animation->tr[1].init(6, false, _vm->_animation); _vm->_animation->apped(2, 2); _vm->_animation->tr[1].walkto(3); - _vm->_timeout->addTimer(36, _vm->_timeout->kProcGetTiedUp, _vm->_timeout->kReasonGettingTiedUp); + _vm->_timer->addTimer(36, _vm->_timer->kProcGetTiedUp, _vm->_timer->kReasonGettingTiedUp); } } @@ -572,7 +572,7 @@ void Lucerna::enterRoom(byte room, byte ped) { _vm->_animation->tr[1].init(9, false, _vm->_animation); _vm->_animation->apped(2, 2); _vm->_animation->tr[1].walkto(3); - _vm->_timeout->addTimer(47, _vm->_timeout->kProcCardiffSurvey, _vm->_timeout->kReasonCardiffsurvey); + _vm->_timer->addTimer(47, _vm->_timer->kProcCardiffSurvey, _vm->_timer->kReasonCardiffsurvey); } break; case 5 : @@ -582,7 +582,7 @@ void Lucerna::enterRoom(byte room, byte ped) { _vm->_animation->tr[1].init(9, false, _vm->_animation); _vm->_animation->apped(2, 3); _vm->_animation->tr[1]._facingDir = Animation::kDirRight; - _vm->_timeout->addTimer(3, _vm->_timeout->kProcCardiffReturn, _vm->_timeout->kReasonCardiffsurvey); + _vm->_timer->addTimer(3, _vm->_timer->kProcCardiffReturn, _vm->_timer->kReasonCardiffsurvey); } } if (_vm->_gyro->_dna._cardiffQuestionNum < 5) @@ -650,10 +650,10 @@ void Lucerna::enterRoom(byte room, byte ped) { case r__lustiesroom: _vm->_gyro->_dna._dogFoodPos = 1; // Actually, du Lustie pos. if (_vm->_animation->tr[0]._id == 0) // Avvy in his normal clothes - _vm->_timeout->addTimer(3, _vm->_timeout->kProcCallsGuards, _vm->_timeout->kReasonDuLustieTalks); + _vm->_timer->addTimer(3, _vm->_timer->kProcCallsGuards, _vm->_timer->kReasonDuLustieTalks); else if (! _vm->_gyro->_dna._enteredLustiesRoomAsMonk) // already // Presumably, Avvy dressed as a monk. - _vm->_timeout->addTimer(3, _vm->_timeout->kProcGreetsMonk, _vm->_timeout->kReasonDuLustieTalks); + _vm->_timer->addTimer(3, _vm->_timer->kProcGreetsMonk, _vm->_timer->kReasonDuLustieTalks); if (_vm->_gyro->_dna._geidaFollows) { putGeidaAt(5, ped); @@ -1190,7 +1190,7 @@ void Lucerna::gameOver() { _vm->_animation->tr[0]._stepNum = 0; _vm->_animation->tr[0].appear(sx, sy, 0); - _vm->_timeout->addTimer(3, _vm->_timeout->kProcAvalotFalls, _vm->_timeout->kReasonFallingOver); + _vm->_timer->addTimer(3, _vm->_timer->kProcAvalotFalls, _vm->_timer->kReasonFallingOver); _vm->_gyro->_alive = false; } diff --git a/engines/avalanche/module.mk b/engines/avalanche/module.mk index c46f8e21f1..0f1722a482 100644 --- a/engines/avalanche/module.mk +++ b/engines/avalanche/module.mk @@ -15,7 +15,7 @@ MODULE_OBJS = \ enid2.o \ celer2.o \ sequence2.o \ - timeout2.o \ + timer.o \ animation.o \ acci2.o \ dropdown2.o \ diff --git a/engines/avalanche/scrolls2.cpp b/engines/avalanche/scrolls2.cpp index 01c61be208..f8972d5bd3 100644 --- a/engines/avalanche/scrolls2.cpp +++ b/engines/avalanche/scrolls2.cpp @@ -35,7 +35,7 @@ #include "avalanche/animation.h" #include "avalanche/acci2.h" #include "avalanche/visa2.h" -#include "avalanche/timeout2.h" +#include "avalanche/timer.h" #include "common/textconsole.h" #include "common/file.h" @@ -219,7 +219,7 @@ void Scrolls::scrollModeMusic() { setReadyLight(0); _vm->_gyro->_seeScroll = false; - _vm->_timeout->addTimer(8, _vm->_timeout->kProcJacquesWakesUp, _vm->_timeout->kReasonJacquesWakingUp); + _vm->_timer->addTimer(8, _vm->_timer->kProcJacquesWakesUp, _vm->_timer->kReasonJacquesWakingUp); warning("STUB: Scrolls::music_scroll()"); return; #if 0 diff --git a/engines/avalanche/sequence2.cpp b/engines/avalanche/sequence2.cpp index 8f8a3db391..48b8017515 100644 --- a/engines/avalanche/sequence2.cpp +++ b/engines/avalanche/sequence2.cpp @@ -31,7 +31,7 @@ #include "avalanche/sequence2.h" #include "avalanche/gyro2.h" -#include "avalanche/timeout2.h" +#include "avalanche/timer.h" #include "avalanche/celer2.h" #include "avalanche/animation.h" @@ -69,8 +69,8 @@ void Sequence::thenFlip(byte where, byte ped) { } void Sequence::startToClose() { - _vm->_timeout->loseTimer(_vm->_timeout->kReasonSequencer); - _vm->_timeout->addTimer(7, _vm->_timeout->kProcSequence, _vm->_timeout->kReasonSequencer); + _vm->_timer->loseTimer(_vm->_timer->kReasonSequencer); + _vm->_timer->addTimer(7, _vm->_timer->kProcSequence, _vm->_timer->kReasonSequencer); } void Sequence::startToOpen() { diff --git a/engines/avalanche/sequence2.h b/engines/avalanche/sequence2.h index 07c90b455b..67650d519d 100644 --- a/engines/avalanche/sequence2.h +++ b/engines/avalanche/sequence2.h @@ -54,7 +54,7 @@ public: private: AvalancheEngine *_vm; - void shoveLeft(); // This PROC is called by Timeout when it's time to do another frame. + void shoveLeft(); // This PROC is called by Timer when it's time to do another frame. }; } // End of namespace Avalanche. diff --git a/engines/avalanche/timeout2.cpp b/engines/avalanche/timeout2.cpp deleted file mode 100644 index 0f484fc5e8..0000000000 --- a/engines/avalanche/timeout2.cpp +++ /dev/null @@ -1,684 +0,0 @@ -/* 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. - * - */ - -/* - * This code is based on the original source code of Lord Avalot d'Argent version 1.3. - * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman. - */ - -/* TIMEOUT The scheduling unit. */ - -#include "avalanche/avalanche.h" - -#include "avalanche/timeout2.h" -#include "avalanche/visa2.h" -#include "avalanche/lucerna2.h" -#include "avalanche/animation.h" -#include "avalanche/scrolls2.h" -#include "avalanche/acci2.h" -#include "avalanche/sequence2.h" -#include "avalanche/enid2.h" -#include "avalanche/pingo2.h" - -#include "common/textconsole.h" - -namespace Avalanche { - -Timeout::Timeout(AvalancheEngine *vm) { - _vm = vm; - - for (byte i = 0; i < 7; i++) { - _times[i]._timeLeft = 0; - _times[i]._action = 0; - _times[i]._reason = 0; - } - _timerLost = false; -} - -/** - * Add a nex timer - * @remarks Originally called 'set_up_timer' - */ -void Timeout::addTimer(int32 duration, byte action, byte reason) { - if ((_vm->_gyro->isLoaded == false) || (_timerLost == true)) { - byte i = 0; - while ((i < 7) && (_times[i]._timeLeft != 0)) - i++; - - if (i == 7) - return; // Oh dear... No timer left - - // Everything's OK here! - _times[i]._timeLeft = duration; - _times[i]._action = action; - _times[i]._reason = reason; - } else { - _vm->_gyro->isLoaded = false; - return; - } -} - -/** - * Update the timers - * @remarks Originally called 'one_tick' - */ -void Timeout::updateTimer() { - if (_vm->_gyro->_dropdownActive) - return; - - for (byte i = 0; i < 7; i++) { - if (_times[i]._timeLeft <= 0) - continue; - - _times[i]._timeLeft--; - - if (_times[i]._timeLeft == 0) { - switch (_times[i]._action) { - case kProcOpenDrawbridge : - openDrawbridge(); - break; - case kProcAvariciusTalks : - avariciusTalks(); - break; - case kProcUrinate : - urinate(); - break; - case kProcToilet : - toilet(); - break; - case kProcBang: - bang(); - break; - case kProcBang2: - bang2(); - break; - case kProcStairs: - stairs(); - break; - case kProcCardiffSurvey: - cardiffSurvey(); - break; - case kProcCardiffReturn: - cardiffReturn(); - break; - case kProcCwytalotInHerts: - cwytalotInHerts(); - break; - case kProcGetTiedUp: - getTiedUp(); - break; - case kProcGetTiedUp2: - getTiedUp2(); - break; - case kProcHangAround: - hangAround(); - break; - case kProcHangAround2: - hangAround2(); - break; - case kProcAfterTheShootemup: - afterTheShootemup(); - break; - case kProcJacquesWakesUp: - jacquesWakesUp(); - break; - case kProcNaughtyDuke: - naughtyDuke(); - break; - case kProcNaughtyDuke2: - naughtyDuke2(); - break; - case kProcNaughtyDuke3: - naughtyDuke3(); - break; - case kProcJump: - jump(); - break; - case kProcSequence: - _vm->_sequence->callSequencer(); - break; - case kProcCrapulusSpludOut: - crapulusSaysSpludOut(); - break; - case kProcDawnDelay: - _vm->_lucerna->dawn(); - break; - case kProcBuyDrinks: - buyDrinks(); - break; - case kProcBuyWine: - buyWine(); - break; - case kProcCallsGuards: - callsGuards(); - break; - case kProcGreetsMonk: - greetsMonk(); - break; - case kProcFallDownOubliette: - fallDownOubliette(); - break; - case kProcMeetAvaroid: - meetAvaroid(); - break; - case kProcRiseUpOubliette: - riseUpOubliette(); - break; - case kProcRobinHoodAndGeida: - robinHoodAndGeida(); - break; - case kProcRobinHoodAndGeidaTalk: - robinHoodAndGeidaTalk(); - break; - case kProcAvalotReturns: - avalotReturns(); - break; - case kProcAvvySitDown: - avvySitDown(); - break; - case kProcGhostRoomPhew: - ghostRoomPhew(); - break; - case kProcArkataShouts: - arkataShouts(); - break; - case kProcWinning: - winning(); - break; - case kProcAvalotFalls: - avalotFalls(); - break; - case kProcSpludwickGoesToCauldron: - spludwickGoesToCauldron(); - break; - case kProcSpludwickLeavesCauldron: - spludwickLeavesCauldron(); - break; - case kProcGiveLuteToGeida: - giveLuteToGeida(); - break; - } - } - } - _vm->_gyro->_roomTime++; // Cycles since you've been in this room. - _vm->_gyro->_dna._totalTime++; // Total amount of time for this game. -} - -void Timeout::loseTimer(byte which) { - for (byte i = 0; i < 7; i++) { - if (_times[i]._reason == which) - _times[i]._timeLeft = 0; // Cancel this one! - } - - _timerLost = true; -} - -void Timeout::openDrawbridge() { - _vm->_gyro->_dna._drawbridgeOpen++; - _vm->_celer->drawBackgroundSprite(-1, -1, _vm->_gyro->_dna._drawbridgeOpen - 1); - - if (_vm->_gyro->_dna._drawbridgeOpen == 4) - _vm->_gyro->_magics[1]._operation = _vm->_gyro->kMagicNothing; // You may enter the drawbridge. - else - addTimer(7, kProcOpenDrawbridge, kReasonDrawbridgeFalls); -} - -void Timeout::avariciusTalks() { - _vm->_visa->displayScrollChain('q', _vm->_gyro->_dna._avariciusTalk); - _vm->_gyro->_dna._avariciusTalk++; - - if (_vm->_gyro->_dna._avariciusTalk < 17) - addTimer(177, kProcAvariciusTalks, kReasonAvariciusTalks); - else - _vm->_lucerna->incScore(3); -} - -void Timeout::urinate() { - _vm->_animation->tr[0].turn(Animation::kDirUp); - _vm->_animation->stopWalking(); - _vm->_lucerna->drawDirection(); - addTimer(14, kProcToilet, kReasonGoToToilet); -} - -void Timeout::toilet() { - _vm->_scrolls->displayText("That's better!"); -} - -void Timeout::bang() { - _vm->_scrolls->displayText(Common::String(_vm->_scrolls->kControlItalic) + "< BANG! >"); - addTimer(30, kProcBang2, kReasonExplosion); -} - -void Timeout::bang2() { - _vm->_scrolls->displayText("Hmm... sounds like Spludwick's up to something..."); -} - -void Timeout::stairs() { - _vm->_gyro->blip(); - _vm->_animation->tr[0].walkto(4); - _vm->_celer->drawBackgroundSprite(-1, -1, 2); - _vm->_gyro->_dna._brummieStairs = 2; - _vm->_gyro->_magics[10]._operation = _vm->_gyro->kMagicSpecial; - _vm->_gyro->_magics[10]._data = 2; // Reached the bottom of the stairs. - _vm->_gyro->_magics[3]._operation = _vm->_gyro->kMagicNothing; // Stop them hitting the sides (or the game will hang.) -} - -void Timeout::cardiffSurvey() { - if (_vm->_gyro->_dna._cardiffQuestionNum == 0) { - _vm->_gyro->_dna._cardiffQuestionNum++; - _vm->_visa->displayScrollChain('q', 27); - } - - _vm->_visa->displayScrollChain('z', _vm->_gyro->_dna._cardiffQuestionNum); - _vm->_gyro->_interrogation = _vm->_gyro->_dna._cardiffQuestionNum; - addTimer(182, kProcCardiffSurvey, kReasonCardiffsurvey); -} - -void Timeout::cardiffReturn() { - _vm->_visa->displayScrollChain('q', 28); - cardiffSurvey(); // Add end of question. -} - -void Timeout::cwytalotInHerts() { - _vm->_visa->displayScrollChain('q', 29); -} - -void Timeout::getTiedUp() { - _vm->_visa->displayScrollChain('q', 34); // ...Trouble! - _vm->_gyro->_dna._userMovesAvvy = false; - _vm->_gyro->_dna._beenTiedUp = true; - _vm->_animation->stopWalking(); - _vm->_animation->tr[1].stopWalk(); - _vm->_animation->tr[1].stophoming(); - _vm->_animation->tr[1]._callEachStepFl = true; - _vm->_animation->tr[1]._eachStepProc = _vm->_animation->kProcGrabAvvy; - addTimer(70, kProcGetTiedUp2, kReasonGettingTiedUp); -} - -void Timeout::getTiedUp2() { - _vm->_animation->tr[0].walkto(4); - _vm->_animation->tr[1].walkto(5); - _vm->_gyro->_magics[3]._operation = _vm->_gyro->kMagicNothing; // No effect when you touch the boundaries. - _vm->_gyro->_dna._friarWillTieYouUp = true; -} - -void Timeout::hangAround() { - _vm->_animation->tr[1]._doCheck = false; - _vm->_animation->tr[0].init(7, true, _vm->_animation); // Robin Hood - _vm->_gyro->_whereIs[_vm->_gyro->kPeopleRobinHood - 150] = r__robins; - _vm->_animation->apped(1, 2); - _vm->_visa->displayScrollChain('q', 39); - _vm->_animation->tr[0].walkto(7); - addTimer(55, kProcHangAround2, kReasonHangingAround); -} - -void Timeout::hangAround2() { - _vm->_visa->displayScrollChain('q', 40); - _vm->_animation->tr[1]._vanishIfStill = false; - _vm->_animation->tr[1].walkto(4); - _vm->_gyro->_whereIs[_vm->_gyro->kPeopleFriarTuck - 150] = r__robins; - _vm->_visa->displayScrollChain('q', 41); - _vm->_animation->tr[0].done(); - _vm->_animation->tr[1].done(); // Get rid of Robin Hood and Friar Tuck. - - addTimer(1, kProcAfterTheShootemup, kReasonHangingAround); - // Immediately call the following proc (when you have a chance). - - _vm->_gyro->_dna._tiedUp = false; - - _vm->_enid->backToBootstrap(1); // Call the shoot-'em-up. -} - -void Timeout::afterTheShootemup() { - - _vm->_animation->fliproom(_vm->_gyro->_dna._room, 0); - // Only placed this here to replace the minigame. TODO: Remove it when the shoot em' up is implemented! - - _vm->_animation->tr[0].init(0, true, _vm->_animation); // Avalot. - _vm->_animation->apped(1, 2); - _vm->_gyro->_dna._userMovesAvvy = true; - _vm->_gyro->_dna._objects[_vm->_gyro->kObjectCrossbow - 1] = true; - _vm->_lucerna->refreshObjectList(); - - // Same as the added line above: TODO: Remove it later!!! - _vm->_scrolls->displayText(Common::String("P.S.: There should have been the mini-game called \"shoot em' up\", but I haven't implemented it yet: you get the crossbow automatically.") - + _vm->_scrolls->kControlNewLine + _vm->_scrolls->kControlNewLine + "Peter (uruk)"); - -#if 0 - byte shootscore, gain; - - shootscore = mem[storage_seg * storage_ofs]; - gain = (shootscore + 5) / 10; // Rounding up. - - display(string("\6Your score was ") + strf(shootscore) + '.' + "\r\rYou gain (" + - strf(shootscore) + " 0xF6 10) = " + strf(gain) + " points."); - - if (gain > 20) { - display("But we won't let you have more than 20 points!"); - points(20); - } else - points(gain); -#endif - - warning("STUB: Timeout::after_the_shootemup()"); - - _vm->_visa->displayScrollChain('q', 70); -} - -void Timeout::jacquesWakesUp() { - _vm->_gyro->_dna._jacquesState++; - - switch (_vm->_gyro->_dna._jacquesState) { // Additional pictures. - case 1 : - _vm->_celer->drawBackgroundSprite(-1, -1, 1); // Eyes open. - _vm->_visa->displayScrollChain('Q', 45); - break; - case 2 : // Going through the door. - _vm->_celer->drawBackgroundSprite(-1, -1, 2); // Not on the floor. - _vm->_celer->drawBackgroundSprite(-1, -1, 3); // But going through the door. - _vm->_gyro->_magics[5]._operation = _vm->_gyro->kMagicNothing; // You can't wake him up now. - break; - case 3 : // Gone through the door. - _vm->_celer->drawBackgroundSprite(-1, -1, 2); // Not on the floor, either. - _vm->_celer->drawBackgroundSprite(-1, -1, 4); // He's gone... so the door's open. - _vm->_gyro->_whereIs[_vm->_gyro->kPeopleJacques - 150] = 0; // Gone! - break; - } - - if (_vm->_gyro->_dna._jacquesState == 5) { - _vm->_gyro->_dna._bellsAreRinging = true; - _vm->_gyro->_dna._aylesIsAwake = true; - _vm->_lucerna->incScore(2); - } - - switch (_vm->_gyro->_dna._jacquesState) { - case 1: - case 2: - case 3: - addTimer(12, kProcJacquesWakesUp, kReasonJacquesWakingUp); - break; - case 4: - addTimer(24, kProcJacquesWakesUp, kReasonJacquesWakingUp); - break; - } -} - -void Timeout::naughtyDuke() { // This is when the Duke comes in and takes your money. - _vm->_animation->tr[1].init(9, false, _vm->_animation); // Here comes the Duke. - _vm->_animation->apped(2, 1); // He starts at the door... - _vm->_animation->tr[1].walkto(3); // He walks over to you. - - // Let's get the door opening. - _vm->_celer->drawBackgroundSprite(-1, -1, 1); - _vm->_sequence->firstShow(2); - _vm->_sequence->startToClose(); - - addTimer(50, kProcNaughtyDuke2, kReasonNaughtyDuke); -} - -void Timeout::naughtyDuke2() { - _vm->_visa->displayScrollChain('q', 48); // "Ha ha, it worked again!" - _vm->_animation->tr[1].walkto(1); // Walk to the door. - _vm->_animation->tr[1]._vanishIfStill = true; // Then go away! - addTimer(32, kProcNaughtyDuke3, kReasonNaughtyDuke); -} - -void Timeout::naughtyDuke3() { - _vm->_celer->drawBackgroundSprite(-1, -1, 1); - _vm->_sequence->firstShow(2); - _vm->_sequence->startToClose(); -} - -void Timeout::jump() { - _vm->_gyro->_dna._jumpStatus++; - - switch (_vm->_gyro->_dna._jumpStatus) { - case 1: - case 2: - case 3: - case 5: - case 7: - case 9: - _vm->_animation->tr[0]._y--; - break; - case 12: - case 13: - case 14: - case 16: - case 18: - case 19: - _vm->_animation->tr[0]._y++; - break; - } - - if (_vm->_gyro->_dna._jumpStatus == 20) { // End of jump. - _vm->_gyro->_dna._userMovesAvvy = true; - _vm->_gyro->_dna._jumpStatus = 0; - } else { // Still jumping. - addTimer(1, kProcJump, kReasonJumping); - } - - if ((_vm->_gyro->_dna._jumpStatus == 10) // You're at the highest point of your jump. - && (_vm->_gyro->_dna._room == r__insidecardiffcastle) - && (_vm->_gyro->_dna._arrowInTheDoor == true) - && (_vm->_animation->infield(3))) { // Beside the wall - // Grab the arrow! - if (_vm->_gyro->_dna._carryNum >= kCarryLimit) - _vm->_scrolls->displayText("You fail to grab it, because your hands are full."); - else { - _vm->_celer->drawBackgroundSprite(-1, -1, 2); - _vm->_gyro->_dna._arrowInTheDoor = false; // You've got it. - _vm->_gyro->_dna._objects[_vm->_gyro->kObjectBolt - 1] = true; - _vm->_lucerna->refreshObjectList(); - _vm->_visa->displayScrollChain('q', 50); - _vm->_lucerna->incScore(3); - } - } -} - -void Timeout::crapulusSaysSpludOut() { - _vm->_visa->displayScrollChain('q', 56); - _vm->_gyro->_dna._crapulusWillTell = false; -} - -void Timeout::buyDrinks() { - _vm->_celer->drawBackgroundSprite(-1, -1, 11); // Malagauche gets up again. - _vm->_gyro->_dna._malagauche = 0; - - _vm->_visa->displayScrollChain('D', _vm->_gyro->_dna._drinking); // Display message about it. - _vm->_pingo->wobble(); // Do the special effects. - _vm->_visa->displayScrollChain('D', 1); // That'll be thruppence. - if (_vm->_gyro->decreaseMoney(3)) // Pay 3d. - _vm->_visa->displayScrollChain('D', 3); // Tell 'em you paid up. - _vm->_acci->drink(); -} - -void Timeout::buyWine() { - _vm->_celer->drawBackgroundSprite(-1, -1, 11); // Malagauche gets up again. - _vm->_gyro->_dna._malagauche = 0; - - _vm->_visa->displayScrollChain('D', 50); // You buy the wine. - _vm->_visa->displayScrollChain('D', 1); // It'll be thruppence. - if (_vm->_gyro->decreaseMoney(3)) { - _vm->_visa->displayScrollChain('D', 4); // You paid up. - _vm->_gyro->_dna._objects[_vm->_gyro->kObjectWine - 1] = true; - _vm->_lucerna->refreshObjectList(); - _vm->_gyro->_dna._wineState = 1; // OK Wine. - } -} - -void Timeout::callsGuards() { - _vm->_visa->displayScrollChain('Q', 58); // "GUARDS!!!" - _vm->_lucerna->gameOver(); -} - -void Timeout::greetsMonk() { - _vm->_visa->displayScrollChain('Q', 59); - _vm->_gyro->_dna._enteredLustiesRoomAsMonk = true; -} - -void Timeout::fallDownOubliette() { - _vm->_gyro->_magics[8]._operation = _vm->_gyro->kMagicNothing; - _vm->_animation->tr[0]._moveY++; // Increments dx/dy! - _vm->_animation->tr[0]._y += _vm->_animation->tr[0]._moveY; // Dowwwn we go... - addTimer(3, kProcFallDownOubliette, kReasonFallingDownOubliette); -} - -void Timeout::meetAvaroid() { - if (_vm->_gyro->_dna._metAvaroid) { - _vm->_scrolls->displayText(Common::String("You can't expect to be ") + _vm->_scrolls->kControlItalic + "that" - + _vm->_scrolls->kControlRoman + " lucky twice in a row!"); - _vm->_lucerna->gameOver(); - } else { - _vm->_visa->displayScrollChain('Q', 60); - _vm->_gyro->_dna._metAvaroid = true; - addTimer(1, kProcRiseUpOubliette, kReasonRisingUpOubliette); - - _vm->_animation->tr[0]._facingDir = Animation::kDirLeft; - _vm->_animation->tr[0]._x = 151; - _vm->_animation->tr[0]._moveX = -3; - _vm->_animation->tr[0]._moveY = -5; - - _vm->_gyro->setBackgroundColor(2); - } -} - -void Timeout::riseUpOubliette() { - _vm->_animation->tr[0]._visible = true; - _vm->_animation->tr[0]._moveY++; // Decrements dx/dy! - _vm->_animation->tr[0]._y -= _vm->_animation->tr[0]._moveY; // Uuuupppp we go... - if (_vm->_animation->tr[0]._moveY > 0) - addTimer(3, kProcRiseUpOubliette, kReasonRisingUpOubliette); - else - _vm->_gyro->_dna._userMovesAvvy = true; -} - -void Timeout::robinHoodAndGeida() { - _vm->_animation->tr[0].init(7, true, _vm->_animation); - _vm->_animation->apped(1, 7); - _vm->_animation->tr[0].walkto(6); - _vm->_animation->tr[1].stopWalk(); - _vm->_animation->tr[1]._facingDir = Animation::kDirLeft; - addTimer(20, kProcRobinHoodAndGeidaTalk, kReasonRobinHoodAndGeida); - _vm->_gyro->_dna._geidaFollows = false; -} - -void Timeout::robinHoodAndGeidaTalk() { - _vm->_visa->displayScrollChain('q', 66); - _vm->_animation->tr[0].walkto(2); - _vm->_animation->tr[1].walkto(2); - _vm->_animation->tr[0]._vanishIfStill = true; - _vm->_animation->tr[1]._vanishIfStill = true; - addTimer(162, kProcAvalotReturns, kReasonRobinHoodAndGeida); -} - -void Timeout::avalotReturns() { - _vm->_animation->tr[0].done(); - _vm->_animation->tr[1].done(); - _vm->_animation->tr[0].init(0, true, _vm->_animation); - _vm->_animation->apped(1, 1); - _vm->_visa->displayScrollChain('q', 67); - _vm->_gyro->_dna._userMovesAvvy = true; -} - -/** - * This is used when you sit down in the pub in Notts. It loops around - * so that it will happen when Avvy stops walking. - * @remarks Originally called 'avvy_sit_down' - */ -void Timeout::avvySitDown() { - if (_vm->_animation->tr[0]._homing) // Still walking. - addTimer(1, kProcAvvySitDown, kReasonSittingDown); - else { - _vm->_celer->drawBackgroundSprite(-1, -1, 3); - _vm->_gyro->_dna._sittingInPub = true; - _vm->_gyro->_dna._userMovesAvvy = false; - _vm->_animation->tr[0]._visible = false; - } -} - -void Timeout::ghostRoomPhew() { - _vm->_scrolls->displayText(Common::String(_vm->_scrolls->kControlItalic) + "PHEW!" + _vm->_scrolls->kControlRoman - + " You're glad to get out of " + _vm->_scrolls->kControlItalic + "there!"); -} - -void Timeout::arkataShouts() { - if (_vm->_gyro->_dna._teetotal) - return; - - _vm->_visa->displayScrollChain('q', 76); - addTimer(160, kProcArkataShouts, kReasonArkataShouts); -} - -void Timeout::winning() { - _vm->_visa->displayScrollChain('q', 79); - _vm->_pingo->winningPic(); - - warning("STUB: Timeout::winning()"); -#if 0 - do { - _vm->_lucerna->checkclick(); - } while (!(_vm->_gyro->mrelease == 0)); -#endif - // TODO: To be implemented with Pingo::winningPic(). - - _vm->_lucerna->callVerb(_vm->_acci->kVerbCodeScore); - _vm->_scrolls->displayText(" T H E E N D "); - _vm->_gyro->_letMeOut = true; -} - -void Timeout::avalotFalls() { - if (_vm->_animation->tr[0]._stepNum < 5) { - _vm->_animation->tr[0]._stepNum++; - addTimer(3, kProcAvalotFalls, kReasonFallingOver); - } else { - Common::String toDisplay; - for (byte i = 0; i < 6; i++) - toDisplay += _vm->_scrolls->kControlNewLine; - for (byte i = 0; i < 6; i++) - toDisplay += _vm->_scrolls->kControlInsertSpaces; - toDisplay = toDisplay + _vm->_scrolls->kControlRegister + 'Z' + _vm->_scrolls->kControlIcon; - _vm->_scrolls->displayText(toDisplay); - } -} - -void Timeout::spludwickGoesToCauldron() { - if (_vm->_animation->tr[1]._homing) - addTimer(1, kProcSpludwickGoesToCauldron, kReasonSpludWalk); - else - addTimer(17, kProcSpludwickLeavesCauldron, kReasonSpludWalk); -} - -void Timeout::spludwickLeavesCauldron() { - _vm->_animation->tr[1]._callEachStepFl = true; // So that normal procs will continue. -} - -void Timeout::giveLuteToGeida() { // Moved here from Acci. - _vm->_visa->displayScrollChain('Q', 86); - _vm->_lucerna->incScore(4); - _vm->_gyro->_dna._lustieIsAsleep = true; - _vm->_sequence->firstShow(5); - _vm->_sequence->thenShow(6); // He falls asleep... - _vm->_sequence->startToClose(); // Not really closing, but we're using the same procedure. -} - -} // End of namespace Avalanche. diff --git a/engines/avalanche/timeout2.h b/engines/avalanche/timeout2.h deleted file mode 100644 index 5f1769a663..0000000000 --- a/engines/avalanche/timeout2.h +++ /dev/null @@ -1,180 +0,0 @@ -/* 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. - * - */ - -/* - * This code is based on the original source code of Lord Avalot d'Argent version 1.3. - * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman. - */ - -/* TIMEOUT The scheduling unit. */ - -#ifndef AVALANCHE_TIMEOUT2_H -#define AVALANCHE_TIMEOUT2_H - -#include "common/scummsys.h" - -namespace Avalanche { -class AvalancheEngine; - -class Timeout { -public: - // Reason runs between 1 and 28. - enum Reason { - kReasonDrawbridgeFalls = 2, - kReasonAvariciusTalks = 3, - kReasonGoToToilet = 4, - kReasonExplosion = 5, - kReasonBrummieStairs = 6, - kReasonCardiffsurvey = 7, - kReasonCwytalotInHerts = 8, - kReasonGettingTiedUp = 9, - kReasonHangingAround = 10, // Tied to the tree in Nottingham. - kReasonJacquesWakingUp = 11, - kReasonNaughtyDuke = 12, - kReasonJumping = 13, - kReasonSequencer = 14, - kReasonCrapulusSaysSpludwickOut = 15, - kReasonDawndelay = 16, - kReasonDrinks = 17, - kReasonDuLustieTalks = 18, - kReasonFallingDownOubliette = 19, - kReasonMeetingAvaroid = 20, - kReasonRisingUpOubliette = 21, - kReasonRobinHoodAndGeida = 22, - kReasonSittingDown = 23, - kReasonGhostRoomPhew = 1, - kReasonArkataShouts = 24, - kReasonWinning = 25, - kReasonFallingOver = 26, - kReasonSpludWalk = 27, - kReasonGeidaSings = 28 - }; - - // Proc runs between 1 and 41. - enum Proc { - kProcOpenDrawbridge = 3, - kProcAvariciusTalks = 4, - kProcUrinate = 5, - kProcToilet = 6, - kProcBang = 7, - kProcBang2 = 8, - kProcStairs = 9, - kProcCardiffSurvey = 10, - kProcCardiffReturn = 11, - kProcCwytalotInHerts = 12, - kProcGetTiedUp = 13, - kProcGetTiedUp2 = 1, - kProcHangAround = 14, - kProcHangAround2 = 15, - kProcAfterTheShootemup = 32, - kProcJacquesWakesUp = 16, - kProcNaughtyDuke = 17, - kProcNaughtyDuke2 = 18, - kProcNaughtyDuke3 = 38, - kProcJump = 19, - kProcSequence = 20, - kProcCrapulusSpludOut = 21, - kProcDawnDelay = 22, - kProcBuyDrinks = 23, - kProcBuyWine = 24, - kProcCallsGuards = 25, - kProcGreetsMonk = 26, - kProcFallDownOubliette = 27, - kProcMeetAvaroid = 28, - kProcRiseUpOubliette = 29, - kProcRobinHoodAndGeida = 2, - kProcRobinHoodAndGeidaTalk = 30, - kProcAvalotReturns = 31, - kProcAvvySitDown = 33, // In Nottingham. - kProcGhostRoomPhew = 34, - kProcArkataShouts = 35, - kProcWinning = 36, - kProcAvalotFalls = 37, - kProcSpludwickGoesToCauldron = 39, - kProcSpludwickLeavesCauldron = 40, - kProcGiveLuteToGeida = 41 - }; - - struct TimeType { - int32 _timeLeft; - byte _action; - byte _reason; - }; - - TimeType _times[7]; - bool _timerLost; // Is the timer "lost"? (Because of using loseTimer()) - - Timeout(AvalancheEngine *vm); - - void addTimer(int32 duration, byte action, byte reason); - void updateTimer(); - void loseTimer(byte which); - - // Procedures to do things at the end of amounts of time: - void openDrawbridge(); - void avariciusTalks(); - void urinate(); - void toilet(); - void bang(); - void bang2(); - void stairs(); - void cardiffSurvey(); - void cardiffReturn(); - void cwytalotInHerts(); - void getTiedUp(); - void getTiedUp2(); - void hangAround(); - void hangAround2(); - void afterTheShootemup(); - void jacquesWakesUp(); - void naughtyDuke(); - void naughtyDuke2(); - void naughtyDuke3(); - void jump(); - void crapulusSaysSpludOut(); - void buyDrinks(); - void buyWine(); - void callsGuards(); - void greetsMonk(); - void fallDownOubliette(); - void meetAvaroid(); - void riseUpOubliette(); - void robinHoodAndGeida(); - void robinHoodAndGeidaTalk(); - void avalotReturns(); - void avvySitDown(); - void ghostRoomPhew(); - void arkataShouts(); - void winning(); - void avalotFalls(); - void spludwickGoesToCauldron(); - void spludwickLeavesCauldron(); - void giveLuteToGeida(); - -private: - AvalancheEngine *_vm; - -}; - -} // End of namespace Avalanche. - -#endif // AVALANCHE_TIMEOUT2_H diff --git a/engines/avalanche/timer.cpp b/engines/avalanche/timer.cpp new file mode 100644 index 0000000000..2656aeaa84 --- /dev/null +++ b/engines/avalanche/timer.cpp @@ -0,0 +1,684 @@ +/* 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. + * + */ + +/* + * This code is based on the original source code of Lord Avalot d'Argent version 1.3. + * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman. + */ + +/* Original name: TIMEOUT The scheduling unit. */ + +#include "avalanche/avalanche.h" + +#include "avalanche/timer.h" +#include "avalanche/visa2.h" +#include "avalanche/lucerna2.h" +#include "avalanche/animation.h" +#include "avalanche/scrolls2.h" +#include "avalanche/acci2.h" +#include "avalanche/sequence2.h" +#include "avalanche/enid2.h" +#include "avalanche/pingo2.h" + +#include "common/textconsole.h" + +namespace Avalanche { + +Timer::Timer(AvalancheEngine *vm) { + _vm = vm; + + for (byte i = 0; i < 7; i++) { + _times[i]._timeLeft = 0; + _times[i]._action = 0; + _times[i]._reason = 0; + } + _timerLost = false; +} + +/** + * Add a nex timer + * @remarks Originally called 'set_up_timer' + */ +void Timer::addTimer(int32 duration, byte action, byte reason) { + if ((_vm->_gyro->isLoaded == false) || (_timerLost == true)) { + byte i = 0; + while ((i < 7) && (_times[i]._timeLeft != 0)) + i++; + + if (i == 7) + return; // Oh dear... No timer left + + // Everything's OK here! + _times[i]._timeLeft = duration; + _times[i]._action = action; + _times[i]._reason = reason; + } else { + _vm->_gyro->isLoaded = false; + return; + } +} + +/** + * Update the timers + * @remarks Originally called 'one_tick' + */ +void Timer::updateTimer() { + if (_vm->_gyro->_dropdownActive) + return; + + for (byte i = 0; i < 7; i++) { + if (_times[i]._timeLeft <= 0) + continue; + + _times[i]._timeLeft--; + + if (_times[i]._timeLeft == 0) { + switch (_times[i]._action) { + case kProcOpenDrawbridge : + openDrawbridge(); + break; + case kProcAvariciusTalks : + avariciusTalks(); + break; + case kProcUrinate : + urinate(); + break; + case kProcToilet : + toilet(); + break; + case kProcBang: + bang(); + break; + case kProcBang2: + bang2(); + break; + case kProcStairs: + stairs(); + break; + case kProcCardiffSurvey: + cardiffSurvey(); + break; + case kProcCardiffReturn: + cardiffReturn(); + break; + case kProcCwytalotInHerts: + cwytalotInHerts(); + break; + case kProcGetTiedUp: + getTiedUp(); + break; + case kProcGetTiedUp2: + getTiedUp2(); + break; + case kProcHangAround: + hangAround(); + break; + case kProcHangAround2: + hangAround2(); + break; + case kProcAfterTheShootemup: + afterTheShootemup(); + break; + case kProcJacquesWakesUp: + jacquesWakesUp(); + break; + case kProcNaughtyDuke: + naughtyDuke(); + break; + case kProcNaughtyDuke2: + naughtyDuke2(); + break; + case kProcNaughtyDuke3: + naughtyDuke3(); + break; + case kProcJump: + jump(); + break; + case kProcSequence: + _vm->_sequence->callSequencer(); + break; + case kProcCrapulusSpludOut: + crapulusSaysSpludOut(); + break; + case kProcDawnDelay: + _vm->_lucerna->dawn(); + break; + case kProcBuyDrinks: + buyDrinks(); + break; + case kProcBuyWine: + buyWine(); + break; + case kProcCallsGuards: + callsGuards(); + break; + case kProcGreetsMonk: + greetsMonk(); + break; + case kProcFallDownOubliette: + fallDownOubliette(); + break; + case kProcMeetAvaroid: + meetAvaroid(); + break; + case kProcRiseUpOubliette: + riseUpOubliette(); + break; + case kProcRobinHoodAndGeida: + robinHoodAndGeida(); + break; + case kProcRobinHoodAndGeidaTalk: + robinHoodAndGeidaTalk(); + break; + case kProcAvalotReturns: + avalotReturns(); + break; + case kProcAvvySitDown: + avvySitDown(); + break; + case kProcGhostRoomPhew: + ghostRoomPhew(); + break; + case kProcArkataShouts: + arkataShouts(); + break; + case kProcWinning: + winning(); + break; + case kProcAvalotFalls: + avalotFalls(); + break; + case kProcSpludwickGoesToCauldron: + spludwickGoesToCauldron(); + break; + case kProcSpludwickLeavesCauldron: + spludwickLeavesCauldron(); + break; + case kProcGiveLuteToGeida: + giveLuteToGeida(); + break; + } + } + } + _vm->_gyro->_roomTime++; // Cycles since you've been in this room. + _vm->_gyro->_dna._totalTime++; // Total amount of time for this game. +} + +void Timer::loseTimer(byte which) { + for (byte i = 0; i < 7; i++) { + if (_times[i]._reason == which) + _times[i]._timeLeft = 0; // Cancel this one! + } + + _timerLost = true; +} + +void Timer::openDrawbridge() { + _vm->_gyro->_dna._drawbridgeOpen++; + _vm->_celer->drawBackgroundSprite(-1, -1, _vm->_gyro->_dna._drawbridgeOpen - 1); + + if (_vm->_gyro->_dna._drawbridgeOpen == 4) + _vm->_gyro->_magics[1]._operation = _vm->_gyro->kMagicNothing; // You may enter the drawbridge. + else + addTimer(7, kProcOpenDrawbridge, kReasonDrawbridgeFalls); +} + +void Timer::avariciusTalks() { + _vm->_visa->displayScrollChain('q', _vm->_gyro->_dna._avariciusTalk); + _vm->_gyro->_dna._avariciusTalk++; + + if (_vm->_gyro->_dna._avariciusTalk < 17) + addTimer(177, kProcAvariciusTalks, kReasonAvariciusTalks); + else + _vm->_lucerna->incScore(3); +} + +void Timer::urinate() { + _vm->_animation->tr[0].turn(Animation::kDirUp); + _vm->_animation->stopWalking(); + _vm->_lucerna->drawDirection(); + addTimer(14, kProcToilet, kReasonGoToToilet); +} + +void Timer::toilet() { + _vm->_scrolls->displayText("That's better!"); +} + +void Timer::bang() { + _vm->_scrolls->displayText(Common::String(_vm->_scrolls->kControlItalic) + "< BANG! >"); + addTimer(30, kProcBang2, kReasonExplosion); +} + +void Timer::bang2() { + _vm->_scrolls->displayText("Hmm... sounds like Spludwick's up to something..."); +} + +void Timer::stairs() { + _vm->_gyro->blip(); + _vm->_animation->tr[0].walkto(4); + _vm->_celer->drawBackgroundSprite(-1, -1, 2); + _vm->_gyro->_dna._brummieStairs = 2; + _vm->_gyro->_magics[10]._operation = _vm->_gyro->kMagicSpecial; + _vm->_gyro->_magics[10]._data = 2; // Reached the bottom of the stairs. + _vm->_gyro->_magics[3]._operation = _vm->_gyro->kMagicNothing; // Stop them hitting the sides (or the game will hang.) +} + +void Timer::cardiffSurvey() { + if (_vm->_gyro->_dna._cardiffQuestionNum == 0) { + _vm->_gyro->_dna._cardiffQuestionNum++; + _vm->_visa->displayScrollChain('q', 27); + } + + _vm->_visa->displayScrollChain('z', _vm->_gyro->_dna._cardiffQuestionNum); + _vm->_gyro->_interrogation = _vm->_gyro->_dna._cardiffQuestionNum; + addTimer(182, kProcCardiffSurvey, kReasonCardiffsurvey); +} + +void Timer::cardiffReturn() { + _vm->_visa->displayScrollChain('q', 28); + cardiffSurvey(); // Add end of question. +} + +void Timer::cwytalotInHerts() { + _vm->_visa->displayScrollChain('q', 29); +} + +void Timer::getTiedUp() { + _vm->_visa->displayScrollChain('q', 34); // ...Trouble! + _vm->_gyro->_dna._userMovesAvvy = false; + _vm->_gyro->_dna._beenTiedUp = true; + _vm->_animation->stopWalking(); + _vm->_animation->tr[1].stopWalk(); + _vm->_animation->tr[1].stophoming(); + _vm->_animation->tr[1]._callEachStepFl = true; + _vm->_animation->tr[1]._eachStepProc = _vm->_animation->kProcGrabAvvy; + addTimer(70, kProcGetTiedUp2, kReasonGettingTiedUp); +} + +void Timer::getTiedUp2() { + _vm->_animation->tr[0].walkto(4); + _vm->_animation->tr[1].walkto(5); + _vm->_gyro->_magics[3]._operation = _vm->_gyro->kMagicNothing; // No effect when you touch the boundaries. + _vm->_gyro->_dna._friarWillTieYouUp = true; +} + +void Timer::hangAround() { + _vm->_animation->tr[1]._doCheck = false; + _vm->_animation->tr[0].init(7, true, _vm->_animation); // Robin Hood + _vm->_gyro->_whereIs[_vm->_gyro->kPeopleRobinHood - 150] = r__robins; + _vm->_animation->apped(1, 2); + _vm->_visa->displayScrollChain('q', 39); + _vm->_animation->tr[0].walkto(7); + addTimer(55, kProcHangAround2, kReasonHangingAround); +} + +void Timer::hangAround2() { + _vm->_visa->displayScrollChain('q', 40); + _vm->_animation->tr[1]._vanishIfStill = false; + _vm->_animation->tr[1].walkto(4); + _vm->_gyro->_whereIs[_vm->_gyro->kPeopleFriarTuck - 150] = r__robins; + _vm->_visa->displayScrollChain('q', 41); + _vm->_animation->tr[0].done(); + _vm->_animation->tr[1].done(); // Get rid of Robin Hood and Friar Tuck. + + addTimer(1, kProcAfterTheShootemup, kReasonHangingAround); + // Immediately call the following proc (when you have a chance). + + _vm->_gyro->_dna._tiedUp = false; + + _vm->_enid->backToBootstrap(1); // Call the shoot-'em-up. +} + +void Timer::afterTheShootemup() { + + _vm->_animation->fliproom(_vm->_gyro->_dna._room, 0); + // Only placed this here to replace the minigame. TODO: Remove it when the shoot em' up is implemented! + + _vm->_animation->tr[0].init(0, true, _vm->_animation); // Avalot. + _vm->_animation->apped(1, 2); + _vm->_gyro->_dna._userMovesAvvy = true; + _vm->_gyro->_dna._objects[_vm->_gyro->kObjectCrossbow - 1] = true; + _vm->_lucerna->refreshObjectList(); + + // Same as the added line above: TODO: Remove it later!!! + _vm->_scrolls->displayText(Common::String("P.S.: There should have been the mini-game called \"shoot em' up\", but I haven't implemented it yet: you get the crossbow automatically.") + + _vm->_scrolls->kControlNewLine + _vm->_scrolls->kControlNewLine + "Peter (uruk)"); + +#if 0 + byte shootscore, gain; + + shootscore = mem[storage_seg * storage_ofs]; + gain = (shootscore + 5) / 10; // Rounding up. + + display(string("\6Your score was ") + strf(shootscore) + '.' + "\r\rYou gain (" + + strf(shootscore) + " 0xF6 10) = " + strf(gain) + " points."); + + if (gain > 20) { + display("But we won't let you have more than 20 points!"); + points(20); + } else + points(gain); +#endif + + warning("STUB: Timer::after_the_shootemup()"); + + _vm->_visa->displayScrollChain('q', 70); +} + +void Timer::jacquesWakesUp() { + _vm->_gyro->_dna._jacquesState++; + + switch (_vm->_gyro->_dna._jacquesState) { // Additional pictures. + case 1 : + _vm->_celer->drawBackgroundSprite(-1, -1, 1); // Eyes open. + _vm->_visa->displayScrollChain('Q', 45); + break; + case 2 : // Going through the door. + _vm->_celer->drawBackgroundSprite(-1, -1, 2); // Not on the floor. + _vm->_celer->drawBackgroundSprite(-1, -1, 3); // But going through the door. + _vm->_gyro->_magics[5]._operation = _vm->_gyro->kMagicNothing; // You can't wake him up now. + break; + case 3 : // Gone through the door. + _vm->_celer->drawBackgroundSprite(-1, -1, 2); // Not on the floor, either. + _vm->_celer->drawBackgroundSprite(-1, -1, 4); // He's gone... so the door's open. + _vm->_gyro->_whereIs[_vm->_gyro->kPeopleJacques - 150] = 0; // Gone! + break; + } + + if (_vm->_gyro->_dna._jacquesState == 5) { + _vm->_gyro->_dna._bellsAreRinging = true; + _vm->_gyro->_dna._aylesIsAwake = true; + _vm->_lucerna->incScore(2); + } + + switch (_vm->_gyro->_dna._jacquesState) { + case 1: + case 2: + case 3: + addTimer(12, kProcJacquesWakesUp, kReasonJacquesWakingUp); + break; + case 4: + addTimer(24, kProcJacquesWakesUp, kReasonJacquesWakingUp); + break; + } +} + +void Timer::naughtyDuke() { // This is when the Duke comes in and takes your money. + _vm->_animation->tr[1].init(9, false, _vm->_animation); // Here comes the Duke. + _vm->_animation->apped(2, 1); // He starts at the door... + _vm->_animation->tr[1].walkto(3); // He walks over to you. + + // Let's get the door opening. + _vm->_celer->drawBackgroundSprite(-1, -1, 1); + _vm->_sequence->firstShow(2); + _vm->_sequence->startToClose(); + + addTimer(50, kProcNaughtyDuke2, kReasonNaughtyDuke); +} + +void Timer::naughtyDuke2() { + _vm->_visa->displayScrollChain('q', 48); // "Ha ha, it worked again!" + _vm->_animation->tr[1].walkto(1); // Walk to the door. + _vm->_animation->tr[1]._vanishIfStill = true; // Then go away! + addTimer(32, kProcNaughtyDuke3, kReasonNaughtyDuke); +} + +void Timer::naughtyDuke3() { + _vm->_celer->drawBackgroundSprite(-1, -1, 1); + _vm->_sequence->firstShow(2); + _vm->_sequence->startToClose(); +} + +void Timer::jump() { + _vm->_gyro->_dna._jumpStatus++; + + switch (_vm->_gyro->_dna._jumpStatus) { + case 1: + case 2: + case 3: + case 5: + case 7: + case 9: + _vm->_animation->tr[0]._y--; + break; + case 12: + case 13: + case 14: + case 16: + case 18: + case 19: + _vm->_animation->tr[0]._y++; + break; + } + + if (_vm->_gyro->_dna._jumpStatus == 20) { // End of jump. + _vm->_gyro->_dna._userMovesAvvy = true; + _vm->_gyro->_dna._jumpStatus = 0; + } else { // Still jumping. + addTimer(1, kProcJump, kReasonJumping); + } + + if ((_vm->_gyro->_dna._jumpStatus == 10) // You're at the highest point of your jump. + && (_vm->_gyro->_dna._room == r__insidecardiffcastle) + && (_vm->_gyro->_dna._arrowInTheDoor == true) + && (_vm->_animation->infield(3))) { // Beside the wall + // Grab the arrow! + if (_vm->_gyro->_dna._carryNum >= kCarryLimit) + _vm->_scrolls->displayText("You fail to grab it, because your hands are full."); + else { + _vm->_celer->drawBackgroundSprite(-1, -1, 2); + _vm->_gyro->_dna._arrowInTheDoor = false; // You've got it. + _vm->_gyro->_dna._objects[_vm->_gyro->kObjectBolt - 1] = true; + _vm->_lucerna->refreshObjectList(); + _vm->_visa->displayScrollChain('q', 50); + _vm->_lucerna->incScore(3); + } + } +} + +void Timer::crapulusSaysSpludOut() { + _vm->_visa->displayScrollChain('q', 56); + _vm->_gyro->_dna._crapulusWillTell = false; +} + +void Timer::buyDrinks() { + _vm->_celer->drawBackgroundSprite(-1, -1, 11); // Malagauche gets up again. + _vm->_gyro->_dna._malagauche = 0; + + _vm->_visa->displayScrollChain('D', _vm->_gyro->_dna._drinking); // Display message about it. + _vm->_pingo->wobble(); // Do the special effects. + _vm->_visa->displayScrollChain('D', 1); // That'll be thruppence. + if (_vm->_gyro->decreaseMoney(3)) // Pay 3d. + _vm->_visa->displayScrollChain('D', 3); // Tell 'em you paid up. + _vm->_acci->drink(); +} + +void Timer::buyWine() { + _vm->_celer->drawBackgroundSprite(-1, -1, 11); // Malagauche gets up again. + _vm->_gyro->_dna._malagauche = 0; + + _vm->_visa->displayScrollChain('D', 50); // You buy the wine. + _vm->_visa->displayScrollChain('D', 1); // It'll be thruppence. + if (_vm->_gyro->decreaseMoney(3)) { + _vm->_visa->displayScrollChain('D', 4); // You paid up. + _vm->_gyro->_dna._objects[_vm->_gyro->kObjectWine - 1] = true; + _vm->_lucerna->refreshObjectList(); + _vm->_gyro->_dna._wineState = 1; // OK Wine. + } +} + +void Timer::callsGuards() { + _vm->_visa->displayScrollChain('Q', 58); // "GUARDS!!!" + _vm->_lucerna->gameOver(); +} + +void Timer::greetsMonk() { + _vm->_visa->displayScrollChain('Q', 59); + _vm->_gyro->_dna._enteredLustiesRoomAsMonk = true; +} + +void Timer::fallDownOubliette() { + _vm->_gyro->_magics[8]._operation = _vm->_gyro->kMagicNothing; + _vm->_animation->tr[0]._moveY++; // Increments dx/dy! + _vm->_animation->tr[0]._y += _vm->_animation->tr[0]._moveY; // Dowwwn we go... + addTimer(3, kProcFallDownOubliette, kReasonFallingDownOubliette); +} + +void Timer::meetAvaroid() { + if (_vm->_gyro->_dna._metAvaroid) { + _vm->_scrolls->displayText(Common::String("You can't expect to be ") + _vm->_scrolls->kControlItalic + "that" + + _vm->_scrolls->kControlRoman + " lucky twice in a row!"); + _vm->_lucerna->gameOver(); + } else { + _vm->_visa->displayScrollChain('Q', 60); + _vm->_gyro->_dna._metAvaroid = true; + addTimer(1, kProcRiseUpOubliette, kReasonRisingUpOubliette); + + _vm->_animation->tr[0]._facingDir = Animation::kDirLeft; + _vm->_animation->tr[0]._x = 151; + _vm->_animation->tr[0]._moveX = -3; + _vm->_animation->tr[0]._moveY = -5; + + _vm->_gyro->setBackgroundColor(2); + } +} + +void Timer::riseUpOubliette() { + _vm->_animation->tr[0]._visible = true; + _vm->_animation->tr[0]._moveY++; // Decrements dx/dy! + _vm->_animation->tr[0]._y -= _vm->_animation->tr[0]._moveY; // Uuuupppp we go... + if (_vm->_animation->tr[0]._moveY > 0) + addTimer(3, kProcRiseUpOubliette, kReasonRisingUpOubliette); + else + _vm->_gyro->_dna._userMovesAvvy = true; +} + +void Timer::robinHoodAndGeida() { + _vm->_animation->tr[0].init(7, true, _vm->_animation); + _vm->_animation->apped(1, 7); + _vm->_animation->tr[0].walkto(6); + _vm->_animation->tr[1].stopWalk(); + _vm->_animation->tr[1]._facingDir = Animation::kDirLeft; + addTimer(20, kProcRobinHoodAndGeidaTalk, kReasonRobinHoodAndGeida); + _vm->_gyro->_dna._geidaFollows = false; +} + +void Timer::robinHoodAndGeidaTalk() { + _vm->_visa->displayScrollChain('q', 66); + _vm->_animation->tr[0].walkto(2); + _vm->_animation->tr[1].walkto(2); + _vm->_animation->tr[0]._vanishIfStill = true; + _vm->_animation->tr[1]._vanishIfStill = true; + addTimer(162, kProcAvalotReturns, kReasonRobinHoodAndGeida); +} + +void Timer::avalotReturns() { + _vm->_animation->tr[0].done(); + _vm->_animation->tr[1].done(); + _vm->_animation->tr[0].init(0, true, _vm->_animation); + _vm->_animation->apped(1, 1); + _vm->_visa->displayScrollChain('q', 67); + _vm->_gyro->_dna._userMovesAvvy = true; +} + +/** + * This is used when you sit down in the pub in Notts. It loops around + * so that it will happen when Avvy stops walking. + * @remarks Originally called 'avvy_sit_down' + */ +void Timer::avvySitDown() { + if (_vm->_animation->tr[0]._homing) // Still walking. + addTimer(1, kProcAvvySitDown, kReasonSittingDown); + else { + _vm->_celer->drawBackgroundSprite(-1, -1, 3); + _vm->_gyro->_dna._sittingInPub = true; + _vm->_gyro->_dna._userMovesAvvy = false; + _vm->_animation->tr[0]._visible = false; + } +} + +void Timer::ghostRoomPhew() { + _vm->_scrolls->displayText(Common::String(_vm->_scrolls->kControlItalic) + "PHEW!" + _vm->_scrolls->kControlRoman + + " You're glad to get out of " + _vm->_scrolls->kControlItalic + "there!"); +} + +void Timer::arkataShouts() { + if (_vm->_gyro->_dna._teetotal) + return; + + _vm->_visa->displayScrollChain('q', 76); + addTimer(160, kProcArkataShouts, kReasonArkataShouts); +} + +void Timer::winning() { + _vm->_visa->displayScrollChain('q', 79); + _vm->_pingo->winningPic(); + + warning("STUB: Timer::winning()"); +#if 0 + do { + _vm->_lucerna->checkclick(); + } while (!(_vm->_gyro->mrelease == 0)); +#endif + // TODO: To be implemented with Pingo::winningPic(). + + _vm->_lucerna->callVerb(_vm->_acci->kVerbCodeScore); + _vm->_scrolls->displayText(" T H E E N D "); + _vm->_gyro->_letMeOut = true; +} + +void Timer::avalotFalls() { + if (_vm->_animation->tr[0]._stepNum < 5) { + _vm->_animation->tr[0]._stepNum++; + addTimer(3, kProcAvalotFalls, kReasonFallingOver); + } else { + Common::String toDisplay; + for (byte i = 0; i < 6; i++) + toDisplay += _vm->_scrolls->kControlNewLine; + for (byte i = 0; i < 6; i++) + toDisplay += _vm->_scrolls->kControlInsertSpaces; + toDisplay = toDisplay + _vm->_scrolls->kControlRegister + 'Z' + _vm->_scrolls->kControlIcon; + _vm->_scrolls->displayText(toDisplay); + } +} + +void Timer::spludwickGoesToCauldron() { + if (_vm->_animation->tr[1]._homing) + addTimer(1, kProcSpludwickGoesToCauldron, kReasonSpludWalk); + else + addTimer(17, kProcSpludwickLeavesCauldron, kReasonSpludWalk); +} + +void Timer::spludwickLeavesCauldron() { + _vm->_animation->tr[1]._callEachStepFl = true; // So that normal procs will continue. +} + +void Timer::giveLuteToGeida() { // Moved here from Acci. + _vm->_visa->displayScrollChain('Q', 86); + _vm->_lucerna->incScore(4); + _vm->_gyro->_dna._lustieIsAsleep = true; + _vm->_sequence->firstShow(5); + _vm->_sequence->thenShow(6); // He falls asleep... + _vm->_sequence->startToClose(); // Not really closing, but we're using the same procedure. +} + +} // End of namespace Avalanche. diff --git a/engines/avalanche/timer.h b/engines/avalanche/timer.h new file mode 100644 index 0000000000..c8b664b743 --- /dev/null +++ b/engines/avalanche/timer.h @@ -0,0 +1,180 @@ +/* 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. + * + */ + +/* + * This code is based on the original source code of Lord Avalot d'Argent version 1.3. + * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman. + */ + +/* Original name: TIMEOUT The scheduling unit. */ + +#ifndef AVALANCHE_TIMER_H +#define AVALANCHE_TIMER_H + +#include "common/scummsys.h" + +namespace Avalanche { +class AvalancheEngine; + +class Timer { +public: + // Reason runs between 1 and 28. + enum Reason { + kReasonDrawbridgeFalls = 2, + kReasonAvariciusTalks = 3, + kReasonGoToToilet = 4, + kReasonExplosion = 5, + kReasonBrummieStairs = 6, + kReasonCardiffsurvey = 7, + kReasonCwytalotInHerts = 8, + kReasonGettingTiedUp = 9, + kReasonHangingAround = 10, // Tied to the tree in Nottingham. + kReasonJacquesWakingUp = 11, + kReasonNaughtyDuke = 12, + kReasonJumping = 13, + kReasonSequencer = 14, + kReasonCrapulusSaysSpludwickOut = 15, + kReasonDawndelay = 16, + kReasonDrinks = 17, + kReasonDuLustieTalks = 18, + kReasonFallingDownOubliette = 19, + kReasonMeetingAvaroid = 20, + kReasonRisingUpOubliette = 21, + kReasonRobinHoodAndGeida = 22, + kReasonSittingDown = 23, + kReasonGhostRoomPhew = 1, + kReasonArkataShouts = 24, + kReasonWinning = 25, + kReasonFallingOver = 26, + kReasonSpludWalk = 27, + kReasonGeidaSings = 28 + }; + + // Proc runs between 1 and 41. + enum Proc { + kProcOpenDrawbridge = 3, + kProcAvariciusTalks = 4, + kProcUrinate = 5, + kProcToilet = 6, + kProcBang = 7, + kProcBang2 = 8, + kProcStairs = 9, + kProcCardiffSurvey = 10, + kProcCardiffReturn = 11, + kProcCwytalotInHerts = 12, + kProcGetTiedUp = 13, + kProcGetTiedUp2 = 1, + kProcHangAround = 14, + kProcHangAround2 = 15, + kProcAfterTheShootemup = 32, + kProcJacquesWakesUp = 16, + kProcNaughtyDuke = 17, + kProcNaughtyDuke2 = 18, + kProcNaughtyDuke3 = 38, + kProcJump = 19, + kProcSequence = 20, + kProcCrapulusSpludOut = 21, + kProcDawnDelay = 22, + kProcBuyDrinks = 23, + kProcBuyWine = 24, + kProcCallsGuards = 25, + kProcGreetsMonk = 26, + kProcFallDownOubliette = 27, + kProcMeetAvaroid = 28, + kProcRiseUpOubliette = 29, + kProcRobinHoodAndGeida = 2, + kProcRobinHoodAndGeidaTalk = 30, + kProcAvalotReturns = 31, + kProcAvvySitDown = 33, // In Nottingham. + kProcGhostRoomPhew = 34, + kProcArkataShouts = 35, + kProcWinning = 36, + kProcAvalotFalls = 37, + kProcSpludwickGoesToCauldron = 39, + kProcSpludwickLeavesCauldron = 40, + kProcGiveLuteToGeida = 41 + }; + + struct TimerType { + int32 _timeLeft; + byte _action; + byte _reason; + }; + + TimerType _times[7]; + bool _timerLost; // Is the timer "lost"? (Because of using loseTimer()) + + Timer(AvalancheEngine *vm); + + void addTimer(int32 duration, byte action, byte reason); + void updateTimer(); + void loseTimer(byte which); + + // Procedures to do things at the end of amounts of time: + void openDrawbridge(); + void avariciusTalks(); + void urinate(); + void toilet(); + void bang(); + void bang2(); + void stairs(); + void cardiffSurvey(); + void cardiffReturn(); + void cwytalotInHerts(); + void getTiedUp(); + void getTiedUp2(); + void hangAround(); + void hangAround2(); + void afterTheShootemup(); + void jacquesWakesUp(); + void naughtyDuke(); + void naughtyDuke2(); + void naughtyDuke3(); + void jump(); + void crapulusSaysSpludOut(); + void buyDrinks(); + void buyWine(); + void callsGuards(); + void greetsMonk(); + void fallDownOubliette(); + void meetAvaroid(); + void riseUpOubliette(); + void robinHoodAndGeida(); + void robinHoodAndGeidaTalk(); + void avalotReturns(); + void avvySitDown(); + void ghostRoomPhew(); + void arkataShouts(); + void winning(); + void avalotFalls(); + void spludwickGoesToCauldron(); + void spludwickLeavesCauldron(); + void giveLuteToGeida(); + +private: + AvalancheEngine *_vm; + +}; + +} // End of namespace Avalanche. + +#endif // AVALANCHE_TIMER_H -- cgit v1.2.3