diff options
author | uruk | 2013-09-20 00:23:20 +0200 |
---|---|---|
committer | uruk | 2013-09-20 00:23:20 +0200 |
commit | 5ccff749a5d3bdbc3c9fac3023e5a336f4f8f2c1 (patch) | |
tree | 90f1f7fb0a3c1855ce1a06c3ab09b3bcd6aa1312 | |
parent | 16f5f32376dc6648c5ffb6ca461a45105f4f3435 (diff) | |
download | scummvm-rg350-5ccff749a5d3bdbc3c9fac3023e5a336f4f8f2c1.tar.gz scummvm-rg350-5ccff749a5d3bdbc3c9fac3023e5a336f4f8f2c1.tar.bz2 scummvm-rg350-5ccff749a5d3bdbc3c9fac3023e5a336f4f8f2c1.zip |
AVALANCHE: Add minigame: playing the harp.
-rw-r--r-- | engines/avalanche/gyro.cpp | 2 | ||||
-rw-r--r-- | engines/avalanche/gyro.h | 1 | ||||
-rw-r--r-- | engines/avalanche/scrolls.cpp | 125 |
3 files changed, 104 insertions, 24 deletions
diff --git a/engines/avalanche/gyro.cpp b/engines/avalanche/gyro.cpp index 9d4aa19d1c..0754ae3ca7 100644 --- a/engines/avalanche/gyro.cpp +++ b/engines/avalanche/gyro.cpp @@ -131,8 +131,6 @@ const QuasipedType Gyro::kQuasipeds[16] = { {1, kColorLightgreen, kRoomDucks, kColorDarkgray, kPeopleDrDuck} // P: Duck (screen 51). }; -const char Gyro::kMusicKeys[] = "QWERTYUIOP[]"; - const uint16 Gyro::kNotes[12] = {196, 220, 247, 262, 294, 330, 350, 392, 440, 494, 523, 587}; const TuneType Gyro::kTune = { diff --git a/engines/avalanche/gyro.h b/engines/avalanche/gyro.h index 659d2008ec..51b6c155f1 100644 --- a/engines/avalanche/gyro.h +++ b/engines/avalanche/gyro.h @@ -221,7 +221,6 @@ public: kPitchHigher }; - static const char kMusicKeys[]; static const uint16 kNotes[12]; static const TuneType kTune; diff --git a/engines/avalanche/scrolls.cpp b/engines/avalanche/scrolls.cpp index 83656a365e..9e56170226 100644 --- a/engines/avalanche/scrolls.cpp +++ b/engines/avalanche/scrolls.cpp @@ -131,7 +131,9 @@ void Scrolls::scrollModeNormal() { _vm->getEvent(event); if ((event.type == Common::EVENT_LBUTTONUP) || - ((event.type == Common::EVENT_KEYDOWN) && ((event.kbd.keycode == Common::KEYCODE_ESCAPE) || (event.kbd.keycode == Common::KEYCODE_RETURN) || (event.kbd.keycode == Common::KEYCODE_HASH) || (event.kbd.keycode == Common::KEYCODE_PLUS)))) + ((event.type == Common::EVENT_KEYDOWN) && ((event.kbd.keycode == Common::KEYCODE_ESCAPE) + || (event.kbd.keycode == Common::KEYCODE_RETURN) || (event.kbd.keycode == Common::KEYCODE_HASH) + || (event.kbd.keycode == Common::KEYCODE_PLUS)))) break; } @@ -208,30 +210,111 @@ bool Scrolls::theyMatch(TuneType &played) { void Scrolls::scrollModeMusic() { setReadyLight(3); _vm->_gyro->_seeScroll = true; - CursorMan.showMouse(true); + CursorMan.showMouse(false); _vm->_gyro->newMouse(3); - // Since there are no sounds in the game yet, it's pretty pointless to implement this function further. - // For now we act like the player just played the right tone. -#if 0 - if (they_match(played)) { -#endif - _vm->_gyro->_scReturn = true; - CursorMan.showMouse(false); - setReadyLight(0); - _vm->_gyro->_seeScroll = false; + TuneType played; + for (int i = 0; i < sizeof(played); i++) + played[i] = 0; + byte lastOne = 0, thisOne = 0; - _vm->_timer->addTimer(8, Timer::kProcJacquesWakesUp, Timer::kReasonJacquesWakingUp); - warning("STUB: Scrolls::music_scroll()"); - return; -#if 0 - } + _vm->_gyro->_seeScroll = true; - _vm->_gyro->screturn = false; - CursorMan.showMouse(false); - state(0); - _vm->_gyro->seescroll = false; -#endif + ::Graphics::Surface temp; + temp.copyFrom(_vm->_graphics->_surface); + _vm->_graphics->_surface.copyFrom(_vm->_graphics->_scrolls); // TODO: Rework it using getSubArea !!!!!!! + + Common::Event event; + while (!_vm->shouldQuit()) { + _vm->_graphics->refreshScreen(); + + _vm->getEvent(event); + + // When we stop playing? + if ((event.type == Common::EVENT_LBUTTONDOWN) || + ((event.type == Common::EVENT_KEYDOWN) && ((event.kbd.keycode == Common::KEYCODE_RETURN) || (event.kbd.keycode == Common::KEYCODE_ESCAPE)))) { + _vm->_graphics->_surface.copyFrom(temp); + temp.free(); + _vm->_gyro->_seeScroll = false; + CursorMan.showMouse(true); + return; + } + + // When we DO play: + if ((event.type == Common::EVENT_KEYDOWN) && ((event.kbd.keycode == Common::KEYCODE_q) + || (event.kbd.keycode == Common::KEYCODE_w) || (event.kbd.keycode == Common::KEYCODE_e) + || (event.kbd.keycode == Common::KEYCODE_r) || (event.kbd.keycode == Common::KEYCODE_t) + || (event.kbd.keycode == Common::KEYCODE_y) || (event.kbd.keycode == Common::KEYCODE_u) + || (event.kbd.keycode == Common::KEYCODE_i) || (event.kbd.keycode == Common::KEYCODE_o) + || (event.kbd.keycode == Common::KEYCODE_p) || (event.kbd.keycode == Common::KEYCODE_LEFTBRACKET) + || (event.kbd.keycode == Common::KEYCODE_RIGHTBRACKET))) { + byte value; + switch (event.kbd.keycode) { + case Common::KEYCODE_q: + value = 0; + break; + case Common::KEYCODE_w: + value = 1; + break; + case Common::KEYCODE_e: + value = 2; + break; + case Common::KEYCODE_r: + value = 3; + break; + case Common::KEYCODE_t: + value = 4; + break; + case Common::KEYCODE_y: + value = 5; + break; + case Common::KEYCODE_u: + value = 6; + break; + case Common::KEYCODE_i: + value = 7; + break; + case Common::KEYCODE_o: + value = 8; + break; + case Common::KEYCODE_p: + value = 9; + break; + case Common::KEYCODE_LEFTBRACKET: + value = 10; + break; + case Common::KEYCODE_RIGHTBRACKET: + value = 11; + break; + } + + lastOne = thisOne; + thisOne = value; + + _vm->_sound->playNote(_vm->_gyro->kNotes[thisOne], 100); + + if (!_vm->_gyro->_bellsAreRinging) { // These handle playing the right tune. + if (thisOne < lastOne) + store(Gyro::kPitchLower, played); + else if (thisOne == lastOne) + store(Gyro::kPitchSame, played); + else + store(Gyro::kPitchHigher, played); + } + + if (theyMatch(played)) { + setReadyLight(0); + _vm->_timer->addTimer(8, Timer::kProcJacquesWakesUp, Timer::kReasonJacquesWakingUp); + + + _vm->_graphics->_surface.copyFrom(temp); + temp.free(); + _vm->_gyro->_seeScroll = false; + CursorMan.showMouse(true); + return; + } + } + } } void Scrolls::resetScrollDriver() { |