aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-12-26 22:00:39 +1100
committerPaul Gilbert2014-12-26 22:00:39 +1100
commit1d62e224b98e4d2c9736c4965b3da5735b32c022 (patch)
tree0b6295553aa4312d4784b72fb2266e178964a197 /engines
parenta93177e0b3a7aba23667b1edbf81fe4d949d69b7 (diff)
downloadscummvm-rg350-1d62e224b98e4d2c9736c4965b3da5735b32c022.tar.gz
scummvm-rg350-1d62e224b98e4d2c9736c4965b3da5735b32c022.tar.bz2
scummvm-rg350-1d62e224b98e4d2c9736c4965b3da5735b32c022.zip
XEEN: Implement button handlng and rest of Dark Side title screen
Diffstat (limited to 'engines')
-rw-r--r--engines/xeen/darkside/darkside_game.cpp66
-rw-r--r--engines/xeen/darkside/darkside_game.h2
-rw-r--r--engines/xeen/events.cpp33
-rw-r--r--engines/xeen/events.h6
-rw-r--r--engines/xeen/resources.cpp5
-rw-r--r--engines/xeen/resources.h2
-rw-r--r--engines/xeen/sound.cpp5
-rw-r--r--engines/xeen/sound.h2
8 files changed, 110 insertions, 11 deletions
diff --git a/engines/xeen/darkside/darkside_game.cpp b/engines/xeen/darkside/darkside_game.cpp
index 17a998eb41..c067242431 100644
--- a/engines/xeen/darkside/darkside_game.cpp
+++ b/engines/xeen/darkside/darkside_game.cpp
@@ -35,11 +35,16 @@ void DarkSideEngine::playGame() {
}
void DarkSideEngine::darkSideIntro() {
+ showTitle();
+ if (shouldQuit())
+ return;
+}
+
+void DarkSideEngine::showTitle() {
//sub_28F40
_screen->loadPalette("dark.pal");
- File special("special.bin");
SpriteResource nwc[4] = {
- SpriteResource("nwc1.int"), SpriteResource("nwc2.int"),
+ SpriteResource("nwc1.int"), SpriteResource("nwc2.int"),
SpriteResource("nwc3.int"), SpriteResource("nwc4.int")
};
File voc[3] = {
@@ -57,13 +62,13 @@ void DarkSideEngine::darkSideIntro() {
_screen->draw();
_screen->fade(4);
- bool breakFlag = false;
+ // Initial loop for dragon roaring
int nwcIndex = 0, nwcFrame = 0;
- for (int idx = 0; idx < 55 && !shouldQuit() && !breakFlag; ++idx) {
+ for (int idx = 0; idx < 55 && !shouldQuit(); ++idx) {
// Render the next frame
_events->updateGameCounter();
_screen->vertMerge(0);
- nwc[nwcIndex].draw(*_screen, nwcFrame, Common::Point(0, 0));
+ nwc[nwcIndex].draw(*_screen, nwcFrame);
_screen->draw();
switch (idx) {
@@ -84,13 +89,54 @@ void DarkSideEngine::darkSideIntro() {
while (!shouldQuit() && _events->timeElapsed() < 2) {
_events->pollEventsAndWait();
- Common::KeyState keyState;
- if (_events->getKey(keyState)) {
- if (keyState.keycode == Common::KEYCODE_ESCAPE)
- breakFlag = true;
- }
+ if (_events->isKeyMousePressed())
+ return;
}
}
+
+ // Loop for dragon using flyspray
+ for (int idx = 0; idx < 42 && !shouldQuit(); ++idx) {
+ _events->updateGameCounter();
+ _screen->vertMerge(SCREEN_HEIGHT);
+ nwc[3].draw(*_screen, idx);
+ _screen->draw();
+
+ switch (idx) {
+ case 3:
+ _sound->startMusic(40);
+ break;
+ case 11:
+ _sound->startMusic(0);
+ case 27:
+ case 30:
+ _sound->startMusic(3);
+ break;
+ case 31:
+ _sound->proc2(voc[2]);
+ break;
+ case 33:
+ _sound->startMusic(2);
+ break;
+ default:
+ break;
+ }
+
+ while (!shouldQuit() && _events->timeElapsed() < 2) {
+ _events->pollEventsAndWait();
+ if (_events->isKeyMousePressed())
+ return;
+ }
+ }
+
+ // Pause fora bit
+ while (!shouldQuit() && _events->timeElapsed() < 10) {
+ _events->pollEventsAndWait();
+ if (_events->isKeyMousePressed())
+ return;
+ }
+
+ // TODO: Stop sound and music
+
}
} // End of namespace Xeen
diff --git a/engines/xeen/darkside/darkside_game.h b/engines/xeen/darkside/darkside_game.h
index 827ba2088d..5574d459e1 100644
--- a/engines/xeen/darkside/darkside_game.h
+++ b/engines/xeen/darkside/darkside_game.h
@@ -28,6 +28,8 @@
namespace Xeen {
class DarkSideEngine : virtual public XeenEngine {
+private:
+ void showTitle();
protected:
void darkSideIntro();
diff --git a/engines/xeen/events.cpp b/engines/xeen/events.cpp
index c4adabc433..8e1b207556 100644
--- a/engines/xeen/events.cpp
+++ b/engines/xeen/events.cpp
@@ -86,6 +86,18 @@ void EventsManager::pollEvents() {
case Common::EVENT_KEYDOWN:
_keyCode = event.kbd.keycode;
break;
+ case Common::EVENT_LBUTTONDOWN:
+ _leftButton = true;
+ return;
+ case Common::EVENT_LBUTTONUP:
+ _leftButton = false;
+ return;
+ case Common::EVENT_RBUTTONDOWN:
+ _rightButton = true;
+ return;
+ case Common::EVENT_RBUTTONUP:
+ _rightButton = false;
+ break;
default:
break;
}
@@ -103,7 +115,11 @@ void EventsManager::clearEvents() {
}
-
+void EventsManager::debounceMouse() {
+ while (_leftButton && !_vm->shouldQuit()) {
+ pollEventsAndWait();
+ }
+}
bool EventsManager::getKey(Common::KeyState &key) {
if (_keyCode == Common::KEYCODE_INVALID) {
return false;
@@ -114,6 +130,21 @@ bool EventsManager::getKey(Common::KeyState &key) {
}
}
+bool EventsManager::isKeyPending() const {
+ return _keyCode != Common::KEYCODE_INVALID;
+}
+
+/**
+ * Returns true if a key or mouse press is pending
+ */
+bool EventsManager::isKeyMousePressed() {
+ bool result = _leftButton || _rightButton || isKeyPending();
+ debounceMouse();
+ clearEvents();
+
+ return result;
+}
+
/**
* Updates the game counter to match the current frame counter
*/
diff --git a/engines/xeen/events.h b/engines/xeen/events.h
index 4d775ac758..b380f7bb93 100644
--- a/engines/xeen/events.h
+++ b/engines/xeen/events.h
@@ -62,8 +62,14 @@ public:
void clearEvents();
+ void debounceMouse();
+
bool getKey(Common::KeyState &key);
+ bool isKeyPending() const;
+
+ bool isKeyMousePressed();
+
void updateGameCounter();
uint32 timeElapsed();
diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp
index 6690ad08e0..40353c1cdc 100644
--- a/engines/xeen/resources.cpp
+++ b/engines/xeen/resources.cpp
@@ -250,6 +250,11 @@ void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPo
drawOffset(dest, _index[frame]._offset2, destPos);
}
+void SpriteResource::draw(XSurface &dest, int frame) const {
+ draw(dest, frame, Common::Point());
+}
+
+
void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Point &destPos) const {
// Get cell header
Common::MemoryReadStream f(_data, _filesize);
diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h
index fcb184277a..d29f0f125c 100644
--- a/engines/xeen/resources.h
+++ b/engines/xeen/resources.h
@@ -72,6 +72,8 @@ public:
int size() const;
void draw(XSurface &dest, int frame, const Common::Point &destPos) const;
+
+ void draw(XSurface &dest, int frame) const;
};
} // End of namespace Xeen
diff --git a/engines/xeen/sound.cpp b/engines/xeen/sound.cpp
index 2863a3d564..9495b25fe4 100644
--- a/engines/xeen/sound.cpp
+++ b/engines/xeen/sound.cpp
@@ -31,4 +31,9 @@ void SoundManager::proc2(File &f) {
}
+void SoundManager::startMusic(int v1) {
+
+}
+
+
} // End of namespace Xeen
diff --git a/engines/xeen/sound.h b/engines/xeen/sound.h
index 2e163e7cce..b122fc150f 100644
--- a/engines/xeen/sound.h
+++ b/engines/xeen/sound.h
@@ -36,6 +36,8 @@ public:
SoundManager(XeenEngine *vm);
void proc2(File &f);
+
+ void startMusic(int v1);
};
} // End of namespace Xeen