aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/minigames
diff options
context:
space:
mode:
Diffstat (limited to 'engines/gob/minigames')
-rw-r--r--engines/gob/minigames/geisha/diving.cpp155
-rw-r--r--engines/gob/minigames/geisha/diving.h68
-rw-r--r--engines/gob/minigames/geisha/evilfish.cpp163
-rw-r--r--engines/gob/minigames/geisha/evilfish.h86
-rw-r--r--engines/gob/minigames/geisha/penetration.cpp106
-rw-r--r--engines/gob/minigames/geisha/penetration.h61
6 files changed, 639 insertions, 0 deletions
diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp
new file mode 100644
index 0000000000..0d216abf43
--- /dev/null
+++ b/engines/gob/minigames/geisha/diving.cpp
@@ -0,0 +1,155 @@
+/* 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.
+ *
+ */
+
+#include "common/list.h"
+
+#include "gob/global.h"
+#include "gob/util.h"
+#include "gob/draw.h"
+#include "gob/video.h"
+#include "gob/decfile.h"
+#include "gob/anifile.h"
+
+#include "gob/minigames/geisha/evilfish.h"
+#include "gob/minigames/geisha/diving.h"
+
+namespace Gob {
+
+namespace Geisha {
+
+Diving::Diving(GobEngine *vm) : _vm(vm), _background(0),
+ _objects(0), _gui(0), _oko(0), _lungs(0), _heart(0) {
+
+}
+
+Diving::~Diving() {
+ deinit();
+}
+
+bool Diving::play(uint16 playerCount, bool hasPearlLocation) {
+ init();
+ initScreen();
+
+ _vm->_draw->blitInvalidated();
+ _vm->_video->retrace();
+
+ EvilFish shark(*_objects, 320, 0, 14, 8, 9, 3);
+
+ Common::List<ANIObject *> objects;
+
+ objects.push_back(_water);
+ objects.push_back(&shark);
+
+ shark.enter(EvilFish::kDirectionLeft, 90);
+
+ while (!_vm->_util->keyPressed() && !_vm->shouldQuit()) {
+ int16 left, top, right, bottom;
+
+ // Clear the previous animation frames
+ for (Common::List<ANIObject *>::iterator o = objects.reverse_begin();
+ o != objects.end(); --o) {
+
+ (*o)->clear(*_vm->_draw->_backSurface, left, top, right, bottom);
+ _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom);
+ }
+
+ // Draw the current animation frames
+ for (Common::List<ANIObject *>::iterator o = objects.begin();
+ o != objects.end(); ++o) {
+
+ (*o)->draw(*_vm->_draw->_backSurface, left, top, right, bottom);
+ _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom);
+
+ (*o)->advance();
+ }
+
+ _vm->_draw->blitInvalidated();
+
+ _vm->_util->waitEndFrame();
+ _vm->_util->processInput();
+ }
+
+ deinit();
+ return true;
+}
+
+void Diving::init() {
+ _background = new DECFile(_vm, "tperle.dec" , 320, 200);
+ _objects = new ANIFile(_vm, "tperle.ani" , 320);
+ _gui = new ANIFile(_vm, "tperlcpt.ani", 320);
+ _oko = new ANIFile(_vm, "tplonge.ani" , 320);
+
+ _water = new ANIObject(*_objects);
+ _lungs = new ANIObject(*_gui);
+ _heart = new ANIObject(*_gui);
+
+ _water->setAnimation(7);
+ _water->setPosition();
+ _water->setVisible(true);
+
+ _lungs->setAnimation(0);
+ _lungs->setPosition();
+ _lungs->setVisible(true);
+
+ _heart->setAnimation(1);
+ _heart->setPosition();
+ _heart->setVisible(true);
+}
+
+void Diving::deinit() {
+ delete _heart;
+ delete _lungs;
+ delete _water;
+
+ delete _oko;
+ delete _gui;
+ delete _objects;
+ delete _background;
+
+ _water = 0;
+ _heart = 0;
+ _lungs = 0;
+
+ _oko = 0;
+ _gui = 0;
+ _objects = 0;
+ _background = 0;
+}
+
+void Diving::initScreen() {
+ _vm->_util->setFrameRate(15);
+
+ _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
+
+ _vm->_draw->_backSurface->clear();
+ _background->draw(*_vm->_draw->_backSurface);
+
+ int16 left, top, right, bottom;
+ _lungs->draw(*_vm->_draw->_backSurface, left, top, right, bottom);
+ _heart->draw(*_vm->_draw->_backSurface, left, top, right, bottom);
+
+ _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 0, 0, 319, 199);
+}
+
+} // End of namespace Geisha
+
+} // End of namespace Gob
diff --git a/engines/gob/minigames/geisha/diving.h b/engines/gob/minigames/geisha/diving.h
new file mode 100644
index 0000000000..238a1ad75b
--- /dev/null
+++ b/engines/gob/minigames/geisha/diving.h
@@ -0,0 +1,68 @@
+/* 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 GOB_MINIGAMES_GEISHA_DIVING_H
+#define GOB_MINIGAMES_GEISHA_DIVING_H
+
+#include "common/system.h"
+
+namespace Gob {
+
+class GobEngine;
+class DECFile;
+class ANIFile;
+class ANIObject;
+
+namespace Geisha {
+
+/** Geisha's "Diving" minigame. */
+class Diving {
+public:
+ Diving(GobEngine *vm);
+ ~Diving();
+
+ bool play(uint16 playerCount, bool hasPearlLocation);
+
+private:
+ GobEngine *_vm;
+
+ DECFile *_background;
+ ANIFile *_objects;
+ ANIFile *_gui;
+ ANIFile *_oko;
+
+ ANIObject *_water;
+ ANIObject *_lungs;
+ ANIObject *_heart;
+
+
+ void init();
+ void deinit();
+
+ void initScreen();
+};
+
+} // End of namespace Geisha
+
+} // End of namespace Gob
+
+#endif // GOB_MINIGAMES_GEISHA_DIVING_H
diff --git a/engines/gob/minigames/geisha/evilfish.cpp b/engines/gob/minigames/geisha/evilfish.cpp
new file mode 100644
index 0000000000..e2672d75c8
--- /dev/null
+++ b/engines/gob/minigames/geisha/evilfish.cpp
@@ -0,0 +1,163 @@
+/* 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.
+ *
+ */
+
+#include "gob/minigames/geisha/evilfish.h"
+
+namespace Gob {
+
+namespace Geisha {
+
+EvilFish::EvilFish(const ANIFile &ani, uint16 screenWidth,
+ uint16 animSwimLeft, uint16 animSwimRight,
+ uint16 animTurnLeft, uint16 animTurnRight, uint16 animDie) :
+ ANIObject(ani), _screenWidth(screenWidth),
+ _animSwimLeft(animSwimLeft), _animSwimRight(animSwimRight),
+ _animTurnLeft(animTurnLeft), _animTurnRight(animTurnRight), _animDie(animDie),
+ _shouldLeave(false), _state(kStateNone) {
+
+}
+
+EvilFish::~EvilFish() {
+}
+
+bool EvilFish::isIn(int16 x, int16 y) const {
+ int16 frameX, frameY, frameWidth, frameHeight;
+ getFramePosition(frameX, frameY);
+ getFrameSize(frameWidth, frameHeight);
+
+ if ((x < frameX) || (y < frameY))
+ return false;
+ if ((x > (frameX + frameWidth)) || (y > (frameY + frameHeight)))
+ return false;
+
+ return true;
+}
+
+void EvilFish::enter(Direction from, int16 y) {
+ _shouldLeave = false;
+
+ bool left = from == kDirectionLeft;
+
+ setAnimation(left ? _animSwimLeft : _animSwimRight);
+
+ int16 width, height;
+ getFrameSize(width, height);
+
+ setPosition(left ? -width : _screenWidth, y);
+ setVisible(true);
+
+ _state = left ? kStateSwimLeft : kStateSwimRight;
+}
+
+void EvilFish::leave() {
+ if (_state == kStateNone)
+ return;
+
+ _shouldLeave = true;
+}
+
+void EvilFish::die() {
+ if ((_state == kStateNone) || (_state == kStateDie))
+ return;
+
+ int16 x, y;
+ getFramePosition(x, y);
+
+ setAnimation(_animDie);
+ setPosition(x, y);
+
+ _state = kStateDie;
+}
+
+void EvilFish::advance() {
+ if (_state == kStateNone)
+ return;
+
+ bool wasLastFrame = lastFrame();
+
+ ANIObject::advance();
+
+ int16 x, y, width, height;
+ getFramePosition(x, y);
+ getFrameSize(width, height);
+
+ switch (_state) {
+ case kStateNone:
+ break;
+
+ case kStateSwimLeft:
+ if (!_shouldLeave && (x >= _screenWidth - width)) {
+ setAnimation(_animTurnRight);
+ setPosition(x, y);
+ _state = kStateTurnRight;
+ }
+
+ if (_shouldLeave && (x >= _screenWidth)) {
+ setVisible(false);
+
+ _shouldLeave = false;
+ _state = kStateNone;
+ }
+ break;
+
+ case kStateSwimRight:
+ if (!_shouldLeave && (x <= 0)) {
+ setAnimation(_animTurnLeft);
+ setPosition(x, y);
+ _state = kStateTurnLeft;
+ }
+
+ if (_shouldLeave && (x < -width)) {
+ setVisible(false);
+
+ _shouldLeave = false;
+ _state = kStateNone;
+ }
+ break;
+
+ case kStateTurnLeft:
+ if (wasLastFrame) {
+ setAnimation(_animSwimLeft);
+ _state = kStateSwimLeft;
+ }
+ break;
+
+ case kStateTurnRight:
+ if (wasLastFrame) {
+ setAnimation(_animSwimRight);
+ _state = kStateSwimRight;
+ }
+ break;
+
+ case kStateDie:
+ if (wasLastFrame) {
+ setVisible(false);
+
+ _state = kStateNone;
+ }
+ break;
+ }
+}
+
+} // End of namespace Geisha
+
+} // End of namespace Gob
diff --git a/engines/gob/minigames/geisha/evilfish.h b/engines/gob/minigames/geisha/evilfish.h
new file mode 100644
index 0000000000..9144cefb4b
--- /dev/null
+++ b/engines/gob/minigames/geisha/evilfish.h
@@ -0,0 +1,86 @@
+/* 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 GOB_MINIGAMES_GEISHA_EVILFISH_H
+#define GOB_MINIGAMES_GEISHA_EVILFISH_H
+
+#include "gob/aniobject.h"
+
+namespace Gob {
+
+namespace Geisha {
+
+/** An "evil" fish in Geisha's "Diving" minigame. */
+class EvilFish : public ANIObject {
+public:
+ enum Direction {
+ kDirectionLeft,
+ kDirectionRight
+ };
+
+ EvilFish(const ANIFile &ani, uint16 screenWidth,
+ uint16 animSwimLeft, uint16 animSwimRight,
+ uint16 animTurnLeft, uint16 animTurnRight, uint16 animDie);
+ ~EvilFish();
+
+ /** Are there coordinates within the fish's sprite? */
+ bool isIn(int16 x, int16 y) const;
+
+ /** Enter from this direction / screen edge. */
+ void enter(Direction from, int16 y);
+ /** Leave the screen in the current direction. */
+ void leave();
+
+ /** Kill the fish. */
+ void die();
+
+ /** Advance the animation to the next frame. */
+ void advance();
+
+private:
+ enum State {
+ kStateNone,
+ kStateSwimLeft,
+ kStateSwimRight,
+ kStateTurnLeft,
+ kStateTurnRight,
+ kStateDie
+ };
+
+ uint16 _screenWidth;
+
+ uint16 _animSwimLeft;
+ uint16 _animSwimRight;
+ uint16 _animTurnLeft;
+ uint16 _animTurnRight;
+ uint16 _animDie;
+
+ bool _shouldLeave;
+
+ State _state;
+};
+
+} // End of namespace Geisha
+
+} // End of namespace Gob
+
+#endif // GOB_MINIGAMES_GEISHA_EVILFISH_H
diff --git a/engines/gob/minigames/geisha/penetration.cpp b/engines/gob/minigames/geisha/penetration.cpp
new file mode 100644
index 0000000000..4334cae21a
--- /dev/null
+++ b/engines/gob/minigames/geisha/penetration.cpp
@@ -0,0 +1,106 @@
+/* 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.
+ *
+ */
+
+#include "gob/global.h"
+#include "gob/util.h"
+#include "gob/draw.h"
+#include "gob/video.h"
+#include "gob/decfile.h"
+#include "gob/anifile.h"
+
+#include "gob/minigames/geisha/penetration.h"
+
+namespace Gob {
+
+namespace Geisha {
+
+static byte kPalette[48] = {
+ 0x16, 0x16, 0x16,
+ 0x12, 0x14, 0x16,
+ 0x34, 0x00, 0x25,
+ 0x1D, 0x1F, 0x22,
+ 0x24, 0x27, 0x2A,
+ 0x2C, 0x0D, 0x22,
+ 0x2B, 0x2E, 0x32,
+ 0x12, 0x09, 0x20,
+ 0x3D, 0x3F, 0x00,
+ 0x3F, 0x3F, 0x3F,
+ 0x00, 0x00, 0x00,
+ 0x15, 0x15, 0x3F,
+ 0x25, 0x22, 0x2F,
+ 0x1A, 0x14, 0x28,
+ 0x3F, 0x00, 0x00,
+ 0x15, 0x3F, 0x15
+};
+
+Penetration::Penetration(GobEngine *vm) : _vm(vm), _background(0), _objects(0) {
+ _background = new Surface(320, 200, 1);
+}
+
+Penetration::~Penetration() {
+ deinit();
+
+ delete _background;
+}
+
+bool Penetration::play(uint16 var1, uint16 var2, uint16 var3) {
+ init();
+ initScreen();
+
+ _vm->_draw->blitInvalidated();
+ _vm->_video->retrace();
+ while (!_vm->_util->keyPressed() && !_vm->shouldQuit())
+ _vm->_util->longDelay(1);
+
+ deinit();
+ return true;
+}
+
+void Penetration::init() {
+ _background->clear();
+
+ _vm->_video->drawPackedSprite("hyprmef2.cmp", *_background);
+
+ _objects = new ANIFile(_vm, "tcite.ani", 320);
+}
+
+void Penetration::deinit() {
+ delete _objects;
+
+ _objects = 0;
+}
+
+void Penetration::initScreen() {
+ _vm->_util->setFrameRate(15);
+
+ memcpy(_vm->_draw->_vgaPalette , kPalette, 48);
+ memcpy(_vm->_draw->_vgaSmallPalette, kPalette, 48);
+
+ _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
+
+ _vm->_draw->_backSurface->blit(*_background);
+ _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 0, 0, 319, 199);
+}
+
+} // End of namespace Geisha
+
+} // End of namespace Gob
diff --git a/engines/gob/minigames/geisha/penetration.h b/engines/gob/minigames/geisha/penetration.h
new file mode 100644
index 0000000000..c346a7bf5a
--- /dev/null
+++ b/engines/gob/minigames/geisha/penetration.h
@@ -0,0 +1,61 @@
+/* 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 GOB_MINIGAMES_GEISHA_PENETRATION_H
+#define GOB_MINIGAMES_GEISHA_PENETRATION_H
+
+#include "common/system.h"
+
+namespace Gob {
+
+class GobEngine;
+class Surface;
+class ANIFile;
+
+namespace Geisha {
+
+/** Geisha's "Penetration" minigame. */
+class Penetration {
+public:
+ Penetration(GobEngine *vm);
+ ~Penetration();
+
+ bool play(uint16 var1, uint16 var2, uint16 var3);
+
+private:
+ GobEngine *_vm;
+
+ Surface *_background;
+ ANIFile *_objects;
+
+
+ void init();
+ void deinit();
+
+ void initScreen();
+};
+
+} // End of namespace Geisha
+
+} // End of namespace Gob
+
+#endif // GOB_MINIGAMES_GEISHA_PENETRATION_H