aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/minigames/geisha
diff options
context:
space:
mode:
Diffstat (limited to 'engines/gob/minigames/geisha')
-rw-r--r--engines/gob/minigames/geisha/diving.cpp8
-rw-r--r--engines/gob/minigames/geisha/evilfish.cpp2
-rw-r--r--engines/gob/minigames/geisha/evilfish.h2
-rw-r--r--engines/gob/minigames/geisha/meter.cpp26
-rw-r--r--engines/gob/minigames/geisha/meter.h10
-rw-r--r--engines/gob/minigames/geisha/mouth.cpp169
-rw-r--r--engines/gob/minigames/geisha/mouth.h75
-rw-r--r--engines/gob/minigames/geisha/penetration.cpp1421
-rw-r--r--engines/gob/minigames/geisha/penetration.h197
-rw-r--r--engines/gob/minigames/geisha/submarine.cpp256
-rw-r--r--engines/gob/minigames/geisha/submarine.h107
11 files changed, 2233 insertions, 40 deletions
diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp
index 6f4c6e168a..56c7b5213c 100644
--- a/engines/gob/minigames/geisha/diving.cpp
+++ b/engines/gob/minigames/geisha/diving.cpp
@@ -706,16 +706,16 @@ void Diving::updateAnims() {
for (Common::List<ANIObject *>::iterator a = _anims.reverse_begin();
a != _anims.end(); --a) {
- (*a)->clear(*_vm->_draw->_backSurface, left, top, right, bottom);
- _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom);
+ if ((*a)->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 a = _anims.begin();
a != _anims.end(); ++a) {
- (*a)->draw(*_vm->_draw->_backSurface, left, top, right, bottom);
- _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom);
+ if ((*a)->draw(*_vm->_draw->_backSurface, left, top, right, bottom))
+ _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom);
(*a)->advance();
}
diff --git a/engines/gob/minigames/geisha/evilfish.cpp b/engines/gob/minigames/geisha/evilfish.cpp
index c7ef9d5622..05ae9d0ad4 100644
--- a/engines/gob/minigames/geisha/evilfish.cpp
+++ b/engines/gob/minigames/geisha/evilfish.cpp
@@ -171,7 +171,7 @@ void EvilFish::mutate(uint16 animSwimLeft, uint16 animSwimRight,
}
}
-bool EvilFish::isDead() {
+bool EvilFish::isDead() const {
return !isVisible() || (_state == kStateNone) || (_state == kStateDie);
}
diff --git a/engines/gob/minigames/geisha/evilfish.h b/engines/gob/minigames/geisha/evilfish.h
index 81efb676e2..4c82629461 100644
--- a/engines/gob/minigames/geisha/evilfish.h
+++ b/engines/gob/minigames/geisha/evilfish.h
@@ -58,7 +58,7 @@ public:
uint16 animTurnLeft, uint16 animTurnRight, uint16 animDie);
/** Is the fish dead? */
- bool isDead();
+ bool isDead() const;
private:
enum State {
diff --git a/engines/gob/minigames/geisha/meter.cpp b/engines/gob/minigames/geisha/meter.cpp
index e3b9bd1ccf..7ec3119866 100644
--- a/engines/gob/minigames/geisha/meter.cpp
+++ b/engines/gob/minigames/geisha/meter.cpp
@@ -42,6 +42,10 @@ Meter::~Meter() {
delete _surface;
}
+int32 Meter::getMaxValue() const {
+ return _maxValue;
+}
+
int32 Meter::getValue() const {
return _value;
}
@@ -59,22 +63,36 @@ void Meter::setMaxValue() {
setValue(_maxValue);
}
-void Meter::increase(int32 n) {
+int32 Meter::increase(int32 n) {
+ if (n < 0)
+ return decrease(-n);
+
+ int32 overflow = MAX<int32>(0, (_value + n) - _maxValue);
+
int32 value = CLIP<int32>(_value + n, 0, _maxValue);
if (_value == value)
- return;
+ return overflow;
_value = value;
_needUpdate = true;
+
+ return overflow;
}
-void Meter::decrease(int32 n) {
+int32 Meter::decrease(int32 n) {
+ if (n < 0)
+ return increase(-n);
+
+ int32 underflow = -MIN<int32>(0, _value - n);
+
int32 value = CLIP<int32>(_value - n, 0, _maxValue);
if (_value == value)
- return;
+ return underflow;
_value = value;
_needUpdate = true;
+
+ return underflow;
}
void Meter::draw(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom) {
diff --git a/engines/gob/minigames/geisha/meter.h b/engines/gob/minigames/geisha/meter.h
index a9bdb14d0f..30dc826de0 100644
--- a/engines/gob/minigames/geisha/meter.h
+++ b/engines/gob/minigames/geisha/meter.h
@@ -44,6 +44,8 @@ public:
Direction direction);
~Meter();
+ /** Return the max value the meter is measuring. */
+ int32 getMaxValue() const;
/** Return the current value the meter is measuring. */
int32 getValue() const;
@@ -53,10 +55,10 @@ public:
/** Set the current value the meter is measuring to the max value. */
void setMaxValue();
- /** Increase the current value the meter is measuring. */
- void increase(int32 n = 1);
- /** Decrease the current value the meter is measuring. */
- void decrease(int32 n = 1);
+ /** Increase the current value the meter is measuring, returning the overflow. */
+ int32 increase(int32 n = 1);
+ /** Decrease the current value the meter is measuring, returning the underflow. */
+ int32 decrease(int32 n = 1);
/** Draw the meter onto the surface and return the affected rectangle. */
void draw(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom);
diff --git a/engines/gob/minigames/geisha/mouth.cpp b/engines/gob/minigames/geisha/mouth.cpp
new file mode 100644
index 0000000000..7ba9f86f8c
--- /dev/null
+++ b/engines/gob/minigames/geisha/mouth.cpp
@@ -0,0 +1,169 @@
+/* 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/util.h"
+
+#include "gob/minigames/geisha/mouth.h"
+
+namespace Gob {
+
+namespace Geisha {
+
+Mouth::Mouth(const ANIFile &ani, const CMPFile &cmp,
+ uint16 mouthAnim, uint16 mouthSprite, uint16 floorSprite) : ANIObject(ani) {
+
+ _sprite = new ANIObject(cmp);
+ _sprite->setAnimation(mouthSprite);
+ _sprite->setVisible(true);
+
+ for (int i = 0; i < kFloorCount; i++) {
+ _floor[i] = new ANIObject(cmp);
+ _floor[i]->setAnimation(floorSprite);
+ _floor[i]->setVisible(true);
+ }
+
+ _state = kStateDeactivated;
+
+ setAnimation(mouthAnim);
+ setMode(kModeOnce);
+ setPause(true);
+ setVisible(true);
+}
+
+Mouth::~Mouth() {
+ for (int i = 0; i < kFloorCount; i++)
+ delete _floor[i];
+
+ delete _sprite;
+}
+
+void Mouth::advance() {
+ if (_state != kStateActivated)
+ return;
+
+ // Animation finished, set state to dead
+ if (isPaused()) {
+ _state = kStateDead;
+ return;
+ }
+
+ ANIObject::advance();
+}
+
+void Mouth::activate() {
+ if (_state != kStateDeactivated)
+ return;
+
+ _state = kStateActivated;
+
+ setPause(false);
+}
+
+bool Mouth::isDeactivated() const {
+ return _state == kStateDeactivated;
+}
+
+void Mouth::setPosition(int16 x, int16 y) {
+ ANIObject::setPosition(x, y);
+
+ int16 floorWidth, floorHeight;
+ _floor[0]->getFrameSize(floorWidth, floorHeight);
+
+ _sprite->setPosition(x, y);
+
+ for (int i = 0; i < kFloorCount; i++)
+ _floor[i]->setPosition(x + (i * floorWidth), y);
+}
+
+bool Mouth::draw(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom) {
+ // If the mouth is deactivated, draw the default mouth sprite
+ if (_state == kStateDeactivated)
+ return _sprite->draw(dest, left, top, right, bottom);
+
+ // If the mouth is activated, draw the current mouth animation sprite
+ if (_state == kStateActivated)
+ return ANIObject::draw(dest, left, top, right, bottom);
+
+ // If the mouth is dead, draw the floor tiles
+ if (_state == kStateDead) {
+ int16 fLeft, fRight, fTop, fBottom;
+ bool drawn = false;
+
+ left = 0x7FFF;
+ top = 0x7FFF;
+ right = 0;
+ bottom = 0;
+
+ for (int i = 0; i < kFloorCount; i++) {
+ if (_floor[i]->draw(dest, fLeft, fTop, fRight, fBottom)) {
+ drawn = true;
+ left = MIN(left , fLeft);
+ top = MIN(top , fTop);
+ right = MAX(right , fRight);
+ bottom = MAX(bottom, fBottom);
+ }
+ }
+
+ return drawn;
+ }
+
+ return false;
+}
+
+bool Mouth::clear(Surface &dest, int16 &left , int16 &top, int16 &right, int16 &bottom) {
+ // If the mouth is deactivated, clear the default mouth sprite
+ if (_state == kStateDeactivated)
+ return _sprite->clear(dest, left, top, right, bottom);
+
+ // If the mouth is activated, clear the current mouth animation sprite
+ if (_state == kStateActivated)
+ return ANIObject::clear(dest, left, top, right, bottom);
+
+ // If the mouth is clear, draw the floor tiles
+ if (_state == kStateDead) {
+ int16 fLeft, fRight, fTop, fBottom;
+ bool cleared = false;
+
+ left = 0x7FFF;
+ top = 0x7FFF;
+ right = 0;
+ bottom = 0;
+
+ for (int i = 0; i < kFloorCount; i++) {
+ if (_floor[i]->clear(dest, fLeft, fTop, fRight, fBottom)) {
+ cleared = true;
+ left = MIN(left , fLeft);
+ top = MIN(top , fTop);
+ right = MAX(right , fRight);
+ bottom = MAX(bottom, fBottom);
+ }
+ }
+
+ return cleared;
+ }
+
+ return false;
+}
+
+} // End of namespace Geisha
+
+} // End of namespace Gob
diff --git a/engines/gob/minigames/geisha/mouth.h b/engines/gob/minigames/geisha/mouth.h
new file mode 100644
index 0000000000..2e0cfcd5d0
--- /dev/null
+++ b/engines/gob/minigames/geisha/mouth.h
@@ -0,0 +1,75 @@
+/* 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_MOUTH_H
+#define GOB_MINIGAMES_GEISHA_MOUTH_H
+
+#include "gob/aniobject.h"
+
+namespace Gob {
+
+namespace Geisha {
+
+/** A kissing/biting mouth in Geisha's "Penetration" minigame. */
+class Mouth : public ANIObject {
+public:
+ Mouth(const ANIFile &ani, const CMPFile &cmp,
+ uint16 mouthAnim, uint16 mouthSprite, uint16 floorSprite);
+ ~Mouth();
+
+ /** Advance the animation to the next frame. */
+ void advance();
+
+ /** Active the mouth's animation. */
+ void activate();
+
+ /** Is the mouth deactivated? */
+ bool isDeactivated() const;
+
+ /** Set the current position. */
+ void setPosition(int16 x, int16 y);
+
+ /** Draw the current frame onto the surface and return the affected rectangle. */
+ bool draw(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom);
+ /** Draw the current frame from the surface and return the affected rectangle. */
+ bool clear(Surface &dest, int16 &left, int16 &top, int16 &right, int16 &bottom);
+
+private:
+ static const int kFloorCount = 2;
+
+ enum State {
+ kStateDeactivated,
+ kStateActivated,
+ kStateDead
+ };
+
+ ANIObject *_sprite;
+ ANIObject *_floor[kFloorCount];
+
+ State _state;
+};
+
+} // End of namespace Geisha
+
+} // End of namespace Gob
+
+#endif // GOB_MINIGAMES_GEISHA_MOUTH_H
diff --git a/engines/gob/minigames/geisha/penetration.cpp b/engines/gob/minigames/geisha/penetration.cpp
index 121a45bc40..3be9f1f651 100644
--- a/engines/gob/minigames/geisha/penetration.cpp
+++ b/engines/gob/minigames/geisha/penetration.cpp
@@ -20,87 +20,1458 @@
*
*/
+#include "common/events.h"
+
#include "gob/global.h"
#include "gob/util.h"
+#include "gob/palanim.h"
#include "gob/draw.h"
#include "gob/video.h"
#include "gob/decfile.h"
+#include "gob/cmpfile.h"
#include "gob/anifile.h"
+#include "gob/aniobject.h"
+
+#include "gob/sound/sound.h"
#include "gob/minigames/geisha/penetration.h"
+#include "gob/minigames/geisha/meter.h"
+#include "gob/minigames/geisha/mouth.h"
namespace Gob {
namespace Geisha {
-static const 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
+static const int kColorShield = 11;
+static const int kColorHealth = 15;
+static const int kColorBlack = 10;
+static const int kColorFloor = 13;
+static const int kColorFloorText = 14;
+static const int kColorExitText = 15;
+
+enum Sprite {
+ kSpriteFloorShield = 25,
+ kSpriteExit = 29,
+ kSpriteFloor = 30,
+ kSpriteWall = 31,
+ kSpriteMouthBite = 32,
+ kSpriteMouthKiss = 33,
+ kSpriteBulletN = 65,
+ kSpriteBulletS = 66,
+ kSpriteBulletW = 67,
+ kSpriteBulletE = 68,
+ kSpriteBulletSW = 85,
+ kSpriteBulletSE = 86,
+ kSpriteBulletNW = 87,
+ kSpriteBulletNE = 88
+};
+
+enum Animation {
+ kAnimationEnemyRound = 0,
+ kAnimationEnemyRoundExplode = 1,
+ kAnimationEnemySquare = 2,
+ kAnimationEnemySquareExplode = 3,
+ kAnimationMouthKiss = 33,
+ kAnimationMouthBite = 34
+};
+
+static const int kMapTileWidth = 24;
+static const int kMapTileHeight = 24;
+
+static const int kPlayAreaX = 120;
+static const int kPlayAreaY = 7;
+static const int kPlayAreaWidth = 192;
+static const int kPlayAreaHeight = 113;
+
+static const int kPlayAreaBorderWidth = kPlayAreaWidth / 2;
+static const int kPlayAreaBorderHeight = kPlayAreaHeight / 2;
+
+static const int kTextAreaLeft = 9;
+static const int kTextAreaTop = 7;
+static const int kTextAreaRight = 104;
+static const int kTextAreaBottom = 107;
+
+static const int kTextAreaBigBottom = 142;
+
+const byte Penetration::kPalettes[kFloorCount][3 * kPaletteSize] = {
+ {
+ 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
+ },
+ {
+ 0x16, 0x16, 0x16,
+ 0x12, 0x14, 0x16,
+ 0x37, 0x00, 0x24,
+ 0x1D, 0x1F, 0x22,
+ 0x24, 0x27, 0x2A,
+ 0x30, 0x0E, 0x16,
+ 0x2B, 0x2E, 0x32,
+ 0x22, 0x0E, 0x26,
+ 0x3D, 0x3F, 0x00,
+ 0x3F, 0x3F, 0x3F,
+ 0x00, 0x00, 0x00,
+ 0x15, 0x15, 0x3F,
+ 0x36, 0x28, 0x36,
+ 0x30, 0x1E, 0x2A,
+ 0x3F, 0x00, 0x00,
+ 0x15, 0x3F, 0x15
+ },
+ {
+ 0x16, 0x16, 0x16,
+ 0x12, 0x14, 0x16,
+ 0x3F, 0x14, 0x22,
+ 0x1D, 0x1F, 0x22,
+ 0x24, 0x27, 0x2A,
+ 0x30, 0x10, 0x10,
+ 0x2B, 0x2E, 0x32,
+ 0x2A, 0x12, 0x12,
+ 0x3D, 0x3F, 0x00,
+ 0x3F, 0x3F, 0x3F,
+ 0x00, 0x00, 0x00,
+ 0x15, 0x15, 0x3F,
+ 0x3F, 0x23, 0x31,
+ 0x39, 0x20, 0x2A,
+ 0x3F, 0x00, 0x00,
+ 0x15, 0x3F, 0x15
+ }
+};
+
+const byte Penetration::kMaps[kModeCount][kFloorCount][kMapWidth * kMapHeight] = {
+ {
+ { // Real mode, floor 0
+ 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0,
+ 50, 50, 0, 0, 52, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50,
+ 50, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 50,
+ 50, 0, 0, 50, 0, 0, 52, 53, 0, 0, 0, 0, 0, 0, 50, 0, 50,
+ 50, 0, 50, 0, 0, 50, 50, 50, 50, 0, 54, 55, 0, 0, 50, 0, 50,
+ 50, 0, 50, 49, 0, 50, 0, 52, 53, 0, 50, 50, 50, 0, 0, 0, 50,
+ 50, 57, 0, 50, 0, 0, 0, 50, 50, 50, 0, 0, 56, 50, 54, 55, 50,
+ 50, 50, 0, 0, 50, 50, 50, 0, 0, 0, 0, 50, 0, 0, 50, 0, 50,
+ 50, 51, 50, 0, 54, 55, 0, 0, 50, 50, 50, 50, 52, 53, 50, 0, 50,
+ 50, 0, 50, 0, 0, 0, 0, 0, 54, 55, 0, 0, 0, 50, 0, 0, 50,
+ 50, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 50,
+ 50, 50, 0, 52, 53, 0, 0, 0, 0, 0, 0, 52, 53, 0, 0, 50, 50,
+ 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0
+ },
+ { // Real mode, floor 1
+ 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0,
+ 50, 0, 52, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50,
+ 50, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 50,
+ 50, 0, 50, 51, 52, 53, 0, 0, 52, 53, 0, 0, 0, 0, 50, 0, 50,
+ 50, 0, 50, 0, 50, 50, 0, 50, 0, 50, 0, 50, 50, 0, 50, 0, 50,
+ 50, 0, 50, 0, 52, 53, 0, 0, 0, 0, 0, 52, 53, 0, 52, 53, 50,
+ 50, 57, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 50,
+ 50, 0, 50, 52, 53, 0, 0, 52, 53, 0, 0, 0, 0, 0, 54, 55, 50,
+ 50, 0, 50, 0, 50, 0, 50, 50, 0, 50, 50, 0, 50, 0, 50, 50, 50,
+ 50, 0, 50, 49, 0, 0, 52, 53, 0, 52, 53, 0, 0, 0, 50, 56, 50,
+ 50, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 50,
+ 50, 0, 0, 0, 0, 0, 0, 0, 54, 55, 0, 0, 0, 0, 0, 0, 50,
+ 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0
+ },
+ { // Real mode, floor 2
+ 0, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 0,
+ 50, 52, 53, 0, 0, 0, 0, 50, 50, 50, 0, 0, 0, 0, 52, 53, 50,
+ 50, 0, 50, 50, 50, 0, 0, 0, 50, 0, 0, 0, 50, 50, 50, 0, 50,
+ 50, 0, 50, 52, 53, 50, 50, 52, 53, 0, 50, 50, 54, 55, 50, 0, 50,
+ 50, 0, 50, 0, 0, 0, 0, 50, 0, 50, 0, 0, 0, 0, 50, 0, 50,
+ 50, 0, 0, 0, 50, 0, 0, 0, 50, 0, 0, 0, 50, 0, 52, 53, 50,
+ 0, 50, 0, 50, 50, 50, 0, 57, 50, 51, 0, 50, 50, 50, 0, 50, 0,
+ 50, 0, 0, 0, 50, 0, 0, 0, 50, 0, 52, 53, 50, 0, 0, 0, 50,
+ 50, 0, 50, 0, 0, 0, 0, 50, 56, 50, 0, 0, 0, 0, 50, 0, 50,
+ 50, 0, 50, 54, 55, 50, 50, 0, 0, 0, 50, 50, 54, 55, 50, 0, 50,
+ 50, 0, 50, 50, 50, 0, 0, 0, 50, 0, 0, 0, 50, 50, 50, 0, 50,
+ 50, 52, 53, 0, 0, 0, 0, 50, 50, 50, 0, 0, 0, 0, 52, 53, 50,
+ 0, 50, 50, 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, 50, 50, 50, 0
+ }
+ },
+ {
+ { // Test mode, floor 0
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 56, 0, 50, 0, 0, 52, 53, 0, 0, 0, 0, 52, 53, 0, 51, 50,
+ 50, 0, 0, 50, 0, 0, 0, 50, 0, 54, 55, 50, 0, 50, 50, 50, 50,
+ 50, 52, 53, 50, 50, 0, 0, 50, 50, 50, 50, 50, 0, 50, 0, 0, 50,
+ 50, 0, 0, 0, 0, 56, 0, 0, 0, 0, 0, 50, 49, 50, 0, 0, 50,
+ 50, 0, 54, 55, 0, 50, 50, 54, 55, 0, 50, 50, 50, 0, 0, 0, 50,
+ 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 53, 0, 0, 54, 55, 50,
+ 50, 0, 50, 0, 50, 0, 0, 50, 0, 0, 0, 50, 0, 0, 0, 0, 50,
+ 50, 0, 50, 0, 50, 54, 55, 50, 0, 50, 50, 50, 0, 50, 0, 0, 50,
+ 50, 50, 50, 50, 50, 0, 0, 50, 0, 0, 0, 0, 0, 50, 54, 55, 50,
+ 50, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 0, 0, 0, 50,
+ 50, 57, 0, 52, 53, 0, 0, 0, 0, 54, 55, 0, 0, 0, 0, 56, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50
+ },
+ { // Test mode, floor 1
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 52, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50,
+ 50, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 54, 55, 0, 50,
+ 50, 0, 50, 52, 53, 0, 0, 50, 0, 0, 54, 55, 50, 0, 50, 0, 50,
+ 50, 0, 50, 0, 50, 0, 0, 52, 53, 0, 50, 0, 50, 0, 50, 0, 50,
+ 50, 0, 50, 0, 50, 50, 50, 50, 50, 49, 50, 0, 50, 0, 50, 0, 50,
+ 50, 0, 50, 0, 50, 0, 50, 0, 0, 50, 50, 0, 50, 0, 50, 0, 50,
+ 50, 0, 50, 0, 50, 0, 50, 51, 0, 0, 52, 53, 50, 0, 50, 0, 50,
+ 50, 57, 50, 0, 50, 0, 50, 50, 50, 50, 50, 50, 50, 0, 50, 0, 50,
+ 50, 50, 50, 0, 50, 56, 0, 0, 0, 54, 55, 0, 0, 0, 50, 0, 50,
+ 50, 56, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 50,
+ 50, 50, 50, 50, 0, 0, 0, 0, 52, 53, 0, 0, 0, 0, 0, 0, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50
+ },
+ { // Test mode, floor 2
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
+ 50, 57, 50, 54, 55, 0, 50, 54, 55, 0, 50, 0, 52, 53, 50, 51, 50,
+ 50, 0, 50, 0, 50, 0, 50, 0, 0, 0, 50, 0, 50, 0, 50, 0, 50,
+ 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50,
+ 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50,
+ 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50,
+ 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50,
+ 50, 0, 50, 52, 53, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50,
+ 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50,
+ 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50,
+ 50, 0, 0, 0, 50, 0, 50, 0, 50, 0, 0, 0, 50, 0, 50, 0, 50,
+ 50, 0, 0, 0, 50, 52, 53, 0, 50, 52, 53, 56, 50, 0, 54, 55, 50,
+ 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50
+ }
+ }
+};
+
+static const int kLanguageCount = 5;
+static const int kFallbackLanguage = 2; // English
+
+enum String {
+ kString3rdBasement = 0,
+ kString2ndBasement,
+ kString1stBasement,
+ kStringNoExit,
+ kStringYouHave,
+ kString2Exits,
+ kString1Exit,
+ kStringToReach,
+ kStringUpperLevel1,
+ kStringUpperLevel2,
+ kStringLevel0,
+ kStringPenetration,
+ kStringSuccessful,
+ kStringDanger,
+ kStringGynoides,
+ kStringActivated,
+ kStringCount
};
-Penetration::Penetration(GobEngine *vm) : _vm(vm), _background(0), _objects(0) {
+static const char *kStrings[kLanguageCount][kStringCount] = {
+ { // French
+ "3EME SOUS-SOL",
+ "2EME SOUS-SOL",
+ "1ER SOUS-SOL",
+ "SORTIE REFUSEE",
+ "Vous disposez",
+ "de deux sorties",
+ "d\'une sortie",
+ "pour l\'acc\212s au",
+ "niveau",
+ "sup\202rieur",
+ "- NIVEAU 0 -",
+ "PENETRATION",
+ "REUSSIE",
+ "DANGER",
+ "GYNOIDES",
+ "ACTIVEES"
+ },
+ { // German
+ // NOTE: The original had very broken German there. We provide proper(ish) German instead.
+ // B0rken text in the comments after each line
+ "3. UNTERGESCHOSS", // "3. U.-GESCHOSS""
+ "2. UNTERGESCHOSS", // "2. U.-GESCHOSS"
+ "1. UNTERGESCHOSS", // "1. U.-GESCHOSS"
+ "AUSGANG GESPERRT",
+ "Sie haben",
+ "zwei Ausg\204nge", // "zwei Ausgang"
+ "einen Ausgang", // "Fortsetztung"
+ "um das obere", // ""
+ "Stockwerk zu", // ""
+ "erreichen", // ""
+ "- STOCKWERK 0 -", // "0 - HOHE"
+ "PENETRATION", // "DURCHDRIGEN"
+ "ERFOLGREICH", // "ERFOLG"
+ "GEFAHR",
+ "GYNOIDE",
+ "AKTIVIERT",
+ },
+ { // English
+ "3RD BASEMENT",
+ "2ND BASEMENT",
+ "1ST BASEMENT",
+ "NO EXIT",
+ "You have",
+ "2 exits",
+ "1 exit",
+ "to reach upper",
+ "level",
+ "",
+ "- 0 LEVEL -",
+ "PENETRATION",
+ "SUCCESSFUL",
+ "DANGER",
+ "GYNOIDES",
+ "ACTIVATED",
+ },
+ { // Spanish
+ "3ER. SUBSUELO",
+ "2D. SUBSUELO",
+ "1ER. SUBSUELO",
+ "SALIDA RECHAZADA",
+ "Dispones",
+ "de dos salidas",
+ "de una salida",
+ "para acceso al",
+ "nivel",
+ "superior",
+ "- NIVEL 0 -",
+ "PENETRACION",
+ "CONSEGUIDA",
+ "PELIGRO",
+ "GYNOIDAS",
+ "ACTIVADAS",
+ },
+ { // Italian
+ "SOTTOSUOLO 3",
+ "SOTTOSUOLO 2",
+ "SOTTOSUOLO 1",
+ "NON USCITA",
+ "avete",
+ "due uscite",
+ "un\' uscita",
+ "per accedere al",
+ "livello",
+ "superiore",
+ "- LIVELLO 0 -",
+ "PENETRAZIONE",
+ "RIUSCITA",
+ "PERICOLO",
+ "GYNOIDI",
+ "ATTIVATE",
+ }
+};
+
+
+Penetration::MapObject::MapObject(uint16 tX, uint16 tY, uint16 mX, uint16 mY, uint16 w, uint16 h) :
+ tileX(tX), tileY(tY), mapX(mX), mapY(mY), width(w), height(h) {
+
+ isBlocking = true;
+}
+
+Penetration::MapObject::MapObject(uint16 tX, uint16 tY, uint16 w, uint16 h) :
+ tileX(tX), tileY(tY), width(w), height(h) {
+
+ isBlocking = true;
+
+ setMapFromTilePosition();
+}
+
+void Penetration::MapObject::setTileFromMapPosition() {
+ tileX = (mapX + (width / 2)) / kMapTileWidth;
+ tileY = (mapY + (height / 2)) / kMapTileHeight;
+}
+
+void Penetration::MapObject::setMapFromTilePosition() {
+ mapX = tileX * kMapTileWidth;
+ mapY = tileY * kMapTileHeight;
+}
+
+bool Penetration::MapObject::isIn(uint16 mX, uint16 mY) const {
+ if ((mX < mapX) || (mY < mapY))
+ return false;
+ if ((mX > (mapX + width - 1)) || (mY > (mapY + height - 1)))
+ return false;
+
+ return true;
+}
+
+bool Penetration::MapObject::isIn(uint16 mX, uint16 mY, uint16 w, uint16 h) const {
+ return isIn(mX , mY ) ||
+ isIn(mX + w - 1, mY ) ||
+ isIn(mX , mY + h - 1) ||
+ isIn(mX + w - 1, mY + h - 1);
+}
+
+bool Penetration::MapObject::isIn(const MapObject &obj) const {
+ return isIn(obj.mapX, obj.mapY, obj.width, obj.height);
+}
+
+
+Penetration::ManagedMouth::ManagedMouth(uint16 tX, uint16 tY, MouthType t) :
+ MapObject(tX, tY, 0, 0), mouth(0), type(t) {
+
+}
+
+Penetration::ManagedMouth::~ManagedMouth() {
+ delete mouth;
+}
+
+
+Penetration::ManagedSub::ManagedSub(uint16 tX, uint16 tY) :
+ MapObject(tX, tY, kMapTileWidth, kMapTileHeight), sub(0) {
+
+}
+
+Penetration::ManagedSub::~ManagedSub() {
+ delete sub;
+}
+
+
+Penetration::ManagedEnemy::ManagedEnemy() : MapObject(0, 0, 0, 0), enemy(0), dead(false) {
+}
+
+Penetration::ManagedEnemy::~ManagedEnemy() {
+ delete enemy;
+}
+
+void Penetration::ManagedEnemy::clear() {
+ delete enemy;
+
+ enemy = 0;
+}
+
+
+Penetration::ManagedBullet::ManagedBullet() : MapObject(0, 0, 0, 0), bullet(0) {
+}
+
+Penetration::ManagedBullet::~ManagedBullet() {
+ delete bullet;
+}
+
+void Penetration::ManagedBullet::clear() {
+ delete bullet;
+
+ bullet = 0;
+}
+
+
+Penetration::Penetration(GobEngine *vm) : _vm(vm), _background(0), _sprites(0), _objects(0), _sub(0),
+ _shieldMeter(0), _healthMeter(0), _floor(0), _isPlaying(false) {
+
_background = new Surface(320, 200, 1);
+
+ _shieldMeter = new Meter(11, 119, 92, 3, kColorShield, kColorBlack, 920, Meter::kFillToRight);
+ _healthMeter = new Meter(11, 137, 92, 3, kColorHealth, kColorBlack, 920, Meter::kFillToRight);
+
+ _map = new Surface(kMapWidth * kMapTileWidth + kPlayAreaWidth ,
+ kMapHeight * kMapTileHeight + kPlayAreaHeight, 1);
}
Penetration::~Penetration() {
deinit();
+ delete _map;
+
+ delete _shieldMeter;
+ delete _healthMeter;
+
delete _background;
}
-bool Penetration::play(uint16 var1, uint16 var2, uint16 var3) {
+bool Penetration::play(bool hasAccessPass, bool hasMaxEnergy, bool testMode) {
+ _hasAccessPass = hasAccessPass;
+ _hasMaxEnergy = hasMaxEnergy;
+ _testMode = testMode;
+
+ _isPlaying = true;
+
init();
initScreen();
+ drawFloorText();
+
_vm->_draw->blitInvalidated();
_vm->_video->retrace();
- while (!_vm->_util->keyPressed() && !_vm->shouldQuit())
- _vm->_util->longDelay(1);
+
+ while (!_vm->shouldQuit() && !_quit && !isDead() && !hasWon()) {
+ enemiesCreate();
+ bulletsMove();
+ updateAnims();
+
+ // Draw, fade in if necessary and wait for the end of the frame
+ _vm->_draw->blitInvalidated();
+ fadeIn();
+ _vm->_util->waitEndFrame();
+
+ // Handle the input
+ checkInput();
+
+ // Handle the sub movement
+ handleSub();
+
+ // Handle the enemies movement
+ enemiesMove();
+
+ checkExited();
+
+ if (_shotCoolDown > 0)
+ _shotCoolDown--;
+ }
deinit();
- return true;
+ drawEndText();
+
+ _isPlaying = false;
+
+ return hasWon();
+}
+
+bool Penetration::isPlaying() const {
+ return _isPlaying;
+}
+
+void Penetration::cheatWin() {
+ _floor = 3;
}
void Penetration::init() {
+ // Load sounds
+ _vm->_sound->sampleLoad(&_soundShield , SOUND_SND, "boucl.snd");
+ _vm->_sound->sampleLoad(&_soundBite , SOUND_SND, "pervet.snd");
+ _vm->_sound->sampleLoad(&_soundKiss , SOUND_SND, "baise.snd");
+ _vm->_sound->sampleLoad(&_soundShoot , SOUND_SND, "tirgim.snd");
+ _vm->_sound->sampleLoad(&_soundExit , SOUND_SND, "trouve.snd");
+ _vm->_sound->sampleLoad(&_soundExplode, SOUND_SND, "virmor.snd");
+
+ _quit = false;
+ for (int i = 0; i < kKeyCount; i++)
+ _keys[i] = false;
+
_background->clear();
_vm->_video->drawPackedSprite("hyprmef2.cmp", *_background);
+ _sprites = new CMPFile(_vm, "tcifplai.cmp", 320, 200);
_objects = new ANIFile(_vm, "tcite.ani", 320);
+
+ // The shield starts down
+ _shieldMeter->setValue(0);
+
+ // If we don't have the max energy tokens, the health starts at 1/3 strength
+ if (_hasMaxEnergy)
+ _healthMeter->setMaxValue();
+ else
+ _healthMeter->setValue(_healthMeter->getMaxValue() / 3);
+
+ _floor = 0;
+
+ _shotCoolDown = 0;
+
+ createMap();
}
void Penetration::deinit() {
+ _soundShield.free();
+ _soundBite.free();
+ _soundKiss.free();
+ _soundShoot.free();
+ _soundExit.free();
+ _soundExplode.free();
+
+ clearMap();
+
delete _objects;
+ delete _sprites;
_objects = 0;
+ _sprites = 0;
+}
+
+void Penetration::clearMap() {
+ _mapAnims.clear();
+ _anims.clear();
+
+ _blockingObjects.clear();
+
+ _walls.clear();
+ _exits.clear();
+ _shields.clear();
+ _mouths.clear();
+
+ for (int i = 0; i < kEnemyCount; i++)
+ _enemies[i].clear();
+ for (int i = 0; i < kMaxBulletCount; i++)
+ _bullets[i].clear();
+
+ delete _sub;
+
+ _sub = 0;
+
+ _map->fill(kColorBlack);
+}
+
+void Penetration::createMap() {
+ if (_floor >= kFloorCount)
+ error("Geisha: Invalid floor %d in minigame penetration", _floor);
+
+ clearMap();
+
+ const byte *mapTiles = kMaps[_testMode ? 1 : 0][_floor];
+
+ bool exitWorks;
+
+ // Draw the map tiles
+ for (int y = 0; y < kMapHeight; y++) {
+ for (int x = 0; x < kMapWidth; x++) {
+ const byte mapTile = mapTiles[y * kMapWidth + x];
+
+ const int posX = kPlayAreaBorderWidth + x * kMapTileWidth;
+ const int posY = kPlayAreaBorderHeight + y * kMapTileHeight;
+
+ switch (mapTile) {
+ case 0: // Floor
+ _sprites->draw(*_map, kSpriteFloor, posX, posY);
+ break;
+
+ case 49: // Emergency exit (needs access pass)
+
+ exitWorks = _hasAccessPass;
+ if (exitWorks) {
+ _sprites->draw(*_map, kSpriteExit, posX, posY);
+ _exits.push_back(MapObject(x, y, 0, 0));
+ } else {
+ _sprites->draw(*_map, kSpriteWall, posX, posY);
+ _walls.push_back(MapObject(x, y, kMapTileWidth, kMapTileHeight));
+ }
+
+ break;
+
+ case 50: // Wall
+ _sprites->draw(*_map, kSpriteWall, posX, posY);
+ _walls.push_back(MapObject(x, y, kMapTileWidth, kMapTileHeight));
+ break;
+
+ case 51: // Regular exit
+
+ // A regular exit works always in test mode.
+ // But if we're in real mode, and on the last floor, it needs an access pass
+ exitWorks = _testMode || (_floor < 2) || _hasAccessPass;
+
+ if (exitWorks) {
+ _sprites->draw(*_map, kSpriteExit, posX, posY);
+ _exits.push_back(MapObject(x, y, 0, 0));
+ } else {
+ _sprites->draw(*_map, kSpriteWall, posX, posY);
+ _walls.push_back(MapObject(x, y, kMapTileWidth, kMapTileHeight));
+ }
+
+ break;
+
+ case 52: // Left side of biting mouth
+ _mouths.push_back(ManagedMouth(x, y, kMouthTypeBite));
+
+ _mouths.back().mouth =
+ new Mouth(*_objects, *_sprites, kAnimationMouthBite, kSpriteMouthBite, kSpriteFloor);
+
+ _mouths.back().mouth->setPosition(posX, posY);
+ break;
+
+ case 53: // Right side of biting mouth
+ break;
+
+ case 54: // Left side of kissing mouth
+ _mouths.push_back(ManagedMouth(x, y, kMouthTypeKiss));
+
+ _mouths.back().mouth =
+ new Mouth(*_objects, *_sprites, kAnimationMouthKiss, kSpriteMouthKiss, kSpriteFloor);
+
+ _mouths.back().mouth->setPosition(posX, posY);
+ break;
+
+ case 55: // Right side of kissing mouth
+ break;
+
+ case 56: // Shield lying on the floor
+ _sprites->draw(*_map, kSpriteFloor , posX , posY ); // Floor
+ _sprites->draw(*_map, kSpriteFloorShield, posX + 4, posY + 8); // Shield
+
+ _map->fillRect(posX + 4, posY + 8, posX + 7, posY + 18, kColorFloor); // Area left to shield
+ _map->fillRect(posX + 17, posY + 8, posX + 20, posY + 18, kColorFloor); // Area right to shield
+
+ _shields.push_back(MapObject(x, y, 0, 0));
+ break;
+
+ case 57: // Start position
+ _sprites->draw(*_map, kSpriteFloor, posX, posY);
+
+ delete _sub;
+
+ _sub = new ManagedSub(x, y);
+
+ _sub->sub = new Submarine(*_objects);
+ _sub->sub->setPosition(kPlayAreaX + kPlayAreaBorderWidth, kPlayAreaY + kPlayAreaBorderHeight);
+ break;
+ }
+ }
+ }
+
+ if (!_sub)
+ error("Geisha: No starting position in floor %d (testmode: %d)", _floor, _testMode);
+
+ // Walls
+ for (Common::List<MapObject>::iterator w = _walls.begin(); w != _walls.end(); ++w)
+ _blockingObjects.push_back(&*w);
+
+ // Mouths
+ for (Common::List<ManagedMouth>::iterator m = _mouths.begin(); m != _mouths.end(); ++m)
+ _mapAnims.push_back(m->mouth);
+
+ // Sub
+ _blockingObjects.push_back(_sub);
+ _anims.push_back(_sub->sub);
+
+ // Moving enemies
+ for (int i = 0; i < kEnemyCount; i++) {
+ _enemies[i].enemy = new ANIObject(*_objects);
+
+ _enemies[i].enemy->setPause(true);
+ _enemies[i].enemy->setVisible(false);
+
+ _enemies[i].isBlocking = false;
+
+ _blockingObjects.push_back(&_enemies[i]);
+ _mapAnims.push_back(_enemies[i].enemy);
+ }
+
+ // Bullets
+ for (int i = 0; i < kMaxBulletCount; i++) {
+ _bullets[i].bullet = new ANIObject(*_sprites);
+
+ _bullets[i].bullet->setPause(true);
+ _bullets[i].bullet->setVisible(false);
+
+ _bullets[i].isBlocking = false;
+
+ _mapAnims.push_back(_bullets[i].bullet);
+ }
+}
+
+void Penetration::drawFloorText() {
+ _vm->_draw->_backSurface->fillRect(kTextAreaLeft, kTextAreaTop, kTextAreaRight, kTextAreaBottom, kColorBlack);
+ _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, kTextAreaLeft, kTextAreaTop, kTextAreaRight, kTextAreaBottom);
+
+ const Font *font = _vm->_draw->_fonts[2];
+ if (!font)
+ return;
+
+ const char **strings = kStrings[getLanguage()];
+
+ const char *floorString = 0;
+ if (_floor == 0)
+ floorString = strings[kString3rdBasement];
+ else if (_floor == 1)
+ floorString = strings[kString2ndBasement];
+ else if (_floor == 2)
+ floorString = strings[kString1stBasement];
+
+ if (floorString)
+ _vm->_draw->drawString(floorString, 10, 15, kColorFloorText, kColorBlack, 1,
+ *_vm->_draw->_backSurface, *font);
+
+ if (_exits.size() > 0) {
+ int exitCount = kString2Exits;
+ if (_exits.size() == 1)
+ exitCount = kString1Exit;
+
+ _vm->_draw->drawString(strings[kStringYouHave] , 10, 38, kColorExitText, kColorBlack, 1,
+ *_vm->_draw->_backSurface, *font);
+ _vm->_draw->drawString(strings[exitCount] , 10, 53, kColorExitText, kColorBlack, 1,
+ *_vm->_draw->_backSurface, *font);
+ _vm->_draw->drawString(strings[kStringToReach] , 10, 68, kColorExitText, kColorBlack, 1,
+ *_vm->_draw->_backSurface, *font);
+ _vm->_draw->drawString(strings[kStringUpperLevel1], 10, 84, kColorExitText, kColorBlack, 1,
+ *_vm->_draw->_backSurface, *font);
+ _vm->_draw->drawString(strings[kStringUpperLevel2], 10, 98, kColorExitText, kColorBlack, 1,
+ *_vm->_draw->_backSurface, *font);
+
+ } else
+ _vm->_draw->drawString(strings[kStringNoExit], 10, 53, kColorExitText, kColorBlack, 1,
+ *_vm->_draw->_backSurface, *font);
+}
+
+void Penetration::drawEndText() {
+ // Only draw the end text when we've won and this isn't a test run
+ if (!hasWon() || _testMode)
+ return;
+
+ _vm->_draw->_backSurface->fillRect(kTextAreaLeft, kTextAreaTop, kTextAreaRight, kTextAreaBigBottom, kColorBlack);
+
+ const Font *font = _vm->_draw->_fonts[2];
+ if (!font)
+ return;
+
+ const char **strings = kStrings[getLanguage()];
+
+ _vm->_draw->drawString(strings[kStringLevel0] , 11, 21, kColorExitText, kColorBlack, 1,
+ *_vm->_draw->_backSurface, *font);
+ _vm->_draw->drawString(strings[kStringPenetration], 11, 42, kColorExitText, kColorBlack, 1,
+ *_vm->_draw->_backSurface, *font);
+ _vm->_draw->drawString(strings[kStringSuccessful] , 11, 58, kColorExitText, kColorBlack, 1,
+ *_vm->_draw->_backSurface, *font);
+
+ _vm->_draw->drawString(strings[kStringDanger] , 11, 82, kColorFloorText, kColorBlack, 1,
+ *_vm->_draw->_backSurface, *font);
+ _vm->_draw->drawString(strings[kStringGynoides] , 11, 98, kColorFloorText, kColorBlack, 1,
+ *_vm->_draw->_backSurface, *font);
+ _vm->_draw->drawString(strings[kStringActivated], 11, 113, kColorFloorText, kColorBlack, 1,
+ *_vm->_draw->_backSurface, *font);
+
+ _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, kTextAreaLeft, kTextAreaTop, kTextAreaRight, kTextAreaBigBottom);
+ _vm->_draw->blitInvalidated();
+ _vm->_video->retrace();
+}
+
+void Penetration::fadeIn() {
+ if (!_needFadeIn)
+ return;
+
+ // Fade to palette
+ _vm->_palAnim->fade(_vm->_global->_pPaletteDesc, 0, 0);
+ _needFadeIn = false;
+}
+
+void Penetration::setPalette() {
+ // Fade to black
+ _vm->_palAnim->fade(0, 0, 0);
+
+ // Set palette
+ memcpy(_vm->_draw->_vgaPalette , kPalettes[_floor], 3 * kPaletteSize);
+ memcpy(_vm->_draw->_vgaSmallPalette, kPalettes[_floor], 3 * kPaletteSize);
+
+ _needFadeIn = true;
}
void Penetration::initScreen() {
_vm->_util->setFrameRate(15);
- memcpy(_vm->_draw->_vgaPalette , kPalette, 48);
- memcpy(_vm->_draw->_vgaSmallPalette, kPalette, 48);
+ setPalette();
+
+ // Draw the shield meter
+ _sprites->draw(*_background, 0, 0, 95, 6, 9, 117, 0); // Meter frame
+ _sprites->draw(*_background, 271, 176, 282, 183, 9, 108, 0); // Shield
- _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
+ // Draw the health meter
+ _sprites->draw(*_background, 0, 0, 95, 6, 9, 135, 0); // Meter frame
+ _sprites->draw(*_background, 283, 176, 292, 184, 9, 126, 0); // Heart
_vm->_draw->_backSurface->blit(*_background);
_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 0, 0, 319, 199);
}
+void Penetration::enemiesCreate() {
+ for (int i = 0; i < kEnemyCount; i++) {
+ ManagedEnemy &enemy = _enemies[i];
+
+ if (enemy.enemy->isVisible())
+ continue;
+
+ enemy.enemy->setAnimation((i & 1) ? kAnimationEnemySquare : kAnimationEnemyRound);
+ enemy.enemy->setMode(ANIObject::kModeContinuous);
+ enemy.enemy->setPause(false);
+ enemy.enemy->setVisible(true);
+
+ int16 width, height;
+ enemy.enemy->getFrameSize(width, height);
+
+ enemy.width = width;
+ enemy.height = height;
+
+ do {
+ enemy.mapX = _vm->_util->getRandom(kMapWidth) * kMapTileWidth + 2;
+ enemy.mapY = _vm->_util->getRandom(kMapHeight) * kMapTileHeight + 4;
+ enemy.setTileFromMapPosition();
+ } while (isBlocked(enemy, enemy.mapX, enemy.mapY));
+
+ const int posX = kPlayAreaBorderWidth + enemy.mapX;
+ const int posY = kPlayAreaBorderHeight + enemy.mapY;
+
+ enemy.enemy->setPosition(posX, posY);
+
+ enemy.isBlocking = true;
+ enemy.dead = false;
+ }
+}
+
+void Penetration::enemyMove(ManagedEnemy &enemy, int x, int y) {
+ if ((x == 0) && (y == 0))
+ return;
+
+ MapObject *blockedBy;
+ findPath(enemy, x, y, &blockedBy);
+
+ enemy.setTileFromMapPosition();
+
+ const int posX = kPlayAreaBorderWidth + enemy.mapX;
+ const int posY = kPlayAreaBorderHeight + enemy.mapY;
+
+ enemy.enemy->setPosition(posX, posY);
+
+ if (blockedBy == _sub)
+ enemyAttack(enemy);
+}
+
+void Penetration::enemiesMove() {
+ for (int i = 0; i < kEnemyCount; i++) {
+ ManagedEnemy &enemy = _enemies[i];
+
+ if (!enemy.enemy->isVisible() || enemy.dead)
+ continue;
+
+ int x = 0, y = 0;
+
+ if (enemy.mapX > _sub->mapX)
+ x = -8;
+ else if (enemy.mapX < _sub->mapX)
+ x = 8;
+
+ if (enemy.mapY > _sub->mapY)
+ y = -8;
+ else if (enemy.mapY < _sub->mapY)
+ y = 8;
+
+ enemyMove(enemy, x, y);
+ }
+}
+
+void Penetration::enemyAttack(ManagedEnemy &enemy) {
+ // If we have shields, the enemy explodes at them, taking a huge chunk of energy with it.
+ // Otherwise, the enemy nibbles a small amount of health away.
+
+ if (_shieldMeter->getValue() > 0) {
+ enemyExplode(enemy);
+
+ healthLose(80);
+ } else
+ healthLose(5);
+}
+
+void Penetration::enemyExplode(ManagedEnemy &enemy) {
+ enemy.dead = true;
+ enemy.isBlocking = false;
+
+ bool isSquare = enemy.enemy->getAnimation() == kAnimationEnemySquare;
+
+ enemy.enemy->setAnimation(isSquare ? kAnimationEnemySquareExplode : kAnimationEnemyRoundExplode);
+ enemy.enemy->setMode(ANIObject::kModeOnce);
+
+ _vm->_sound->blasterPlay(&_soundExplode, 1, 0);
+}
+
+void Penetration::checkInput() {
+ Common::Event event;
+ Common::EventManager *eventMan = g_system->getEventManager();
+
+ while (eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ if (event.kbd.keycode == Common::KEYCODE_ESCAPE)
+ _quit = true;
+ else if (event.kbd.keycode == Common::KEYCODE_UP)
+ _keys[kKeyUp ] = true;
+ else if (event.kbd.keycode == Common::KEYCODE_DOWN)
+ _keys[kKeyDown ] = true;
+ else if (event.kbd.keycode == Common::KEYCODE_LEFT)
+ _keys[kKeyLeft ] = true;
+ else if (event.kbd.keycode == Common::KEYCODE_RIGHT)
+ _keys[kKeyRight] = true;
+ else if (event.kbd.keycode == Common::KEYCODE_SPACE)
+ _keys[kKeySpace] = true;
+ else if (event.kbd.keycode == Common::KEYCODE_d) {
+ _vm->getDebugger()->attach();
+ _vm->getDebugger()->onFrame();
+ }
+ break;
+
+ case Common::EVENT_KEYUP:
+ if (event.kbd.keycode == Common::KEYCODE_UP)
+ _keys[kKeyUp ] = false;
+ else if (event.kbd.keycode == Common::KEYCODE_DOWN)
+ _keys[kKeyDown ] = false;
+ else if (event.kbd.keycode == Common::KEYCODE_LEFT)
+ _keys[kKeyLeft ] = false;
+ else if (event.kbd.keycode == Common::KEYCODE_RIGHT)
+ _keys[kKeyRight] = false;
+ else if (event.kbd.keycode == Common::KEYCODE_SPACE)
+ _keys[kKeySpace] = false;
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+void Penetration::handleSub() {
+ int x, y;
+ Submarine::Direction direction = getDirection(x, y);
+
+ subMove(x, y, direction);
+
+ if (_keys[kKeySpace])
+ subShoot();
+}
+
+bool Penetration::isBlocked(const MapObject &self, int16 x, int16 y, MapObject **blockedBy) {
+
+ if ((x < 0) || (y < 0))
+ return true;
+ if (((x + self.width - 1) >= (kMapWidth * kMapTileWidth)) ||
+ ((y + self.height - 1) >= (kMapHeight * kMapTileHeight)))
+ return true;
+
+ MapObject checkSelf(0, 0, self.width, self.height);
+
+ checkSelf.mapX = x;
+ checkSelf.mapY = y;
+
+ for (Common::List<MapObject *>::iterator o = _blockingObjects.begin(); o != _blockingObjects.end(); ++o) {
+ MapObject &obj = **o;
+
+ if (&obj == &self)
+ continue;
+
+ if (!obj.isBlocking)
+ continue;
+
+ if (obj.isIn(checkSelf) || checkSelf.isIn(obj)) {
+ if (blockedBy && !*blockedBy)
+ *blockedBy = &obj;
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void Penetration::findPath(MapObject &obj, int x, int y, MapObject **blockedBy) {
+ if (blockedBy)
+ *blockedBy = 0;
+
+ while ((x != 0) || (y != 0)) {
+ uint16 oldX = obj.mapX;
+ uint16 oldY = obj.mapY;
+
+ uint16 newX = obj.mapX;
+ if (x > 0) {
+ newX++;
+ x--;
+ } else if (x < 0) {
+ newX--;
+ x++;
+ }
+
+ if (!isBlocked(obj, newX, obj.mapY, blockedBy))
+ obj.mapX = newX;
+
+ uint16 newY = obj.mapY;
+ if (y > 0) {
+ newY++;
+ y--;
+ } else if (y < 0) {
+ newY--;
+ y++;
+ }
+
+ if (!isBlocked(obj, obj.mapX, newY, blockedBy))
+ obj.mapY = newY;
+
+ if ((obj.mapX == oldX) && (obj.mapY == oldY))
+ break;
+ }
+}
+
+void Penetration::subMove(int x, int y, Submarine::Direction direction) {
+ if (!_sub->sub->canMove())
+ return;
+
+ if ((x == 0) && (y == 0))
+ return;
+
+ findPath(*_sub, x, y);
+
+ _sub->setTileFromMapPosition();
+
+ _sub->sub->turn(direction);
+
+ checkShields();
+ checkMouths();
+ checkExits();
+}
+
+void Penetration::subShoot() {
+ if (!_sub->sub->canMove() || _sub->sub->isShooting())
+ return;
+
+ if (_shotCoolDown > 0)
+ return;
+
+ // Creating a bullet
+ int slot = findEmptyBulletSlot();
+ if (slot < 0)
+ return;
+
+ ManagedBullet &bullet = _bullets[slot];
+
+ bullet.bullet->setAnimation(directionToBullet(_sub->sub->getDirection()));
+
+ setBulletPosition(*_sub, bullet);
+
+ const int posX = kPlayAreaBorderWidth + bullet.mapX;
+ const int posY = kPlayAreaBorderHeight + bullet.mapY;
+
+ bullet.bullet->setPosition(posX, posY);
+ bullet.bullet->setVisible(true);
+
+ // Shooting
+ _sub->sub->shoot();
+ _vm->_sound->blasterPlay(&_soundShoot, 1, 0);
+
+ _shotCoolDown = 3;
+}
+
+void Penetration::setBulletPosition(const ManagedSub &sub, ManagedBullet &bullet) const {
+ bullet.mapX = sub.mapX;
+ bullet.mapY= sub.mapY;
+
+ int16 sWidth, sHeight;
+ sub.sub->getFrameSize(sWidth, sHeight);
+
+ int16 bWidth, bHeight;
+ bullet.bullet->getFrameSize(bWidth, bHeight);
+
+ switch (sub.sub->getDirection()) {
+ case Submarine::kDirectionN:
+ bullet.mapX += sWidth / 2;
+ bullet.mapY -= bHeight;
+
+ bullet.deltaX = 0;
+ bullet.deltaY = -8;
+ break;
+
+ case Submarine::kDirectionNE:
+ bullet.mapX += sWidth;
+ bullet.mapY -= bHeight * 2;
+
+ bullet.deltaX = 8;
+ bullet.deltaY = -8;
+ break;
+
+ case Submarine::kDirectionE:
+ bullet.mapX += sWidth;
+ bullet.mapY += sHeight / 2 - bHeight;
+
+ bullet.deltaX = 8;
+ bullet.deltaY = 0;
+ break;
+
+ case Submarine::kDirectionSE:
+ bullet.mapX += sWidth;
+ bullet.mapY += sHeight;
+
+ bullet.deltaX = 8;
+ bullet.deltaY = 8;
+ break;
+
+ case Submarine::kDirectionS:
+ bullet.mapX += sWidth / 2;
+ bullet.mapY += sHeight;
+
+ bullet.deltaX = 0;
+ bullet.deltaY = 8;
+ break;
+
+ case Submarine::kDirectionSW:
+ bullet.mapX -= bWidth;
+ bullet.mapY += sHeight;
+
+ bullet.deltaX = -8;
+ bullet.deltaY = 8;
+ break;
+
+ case Submarine::kDirectionW:
+ bullet.mapX -= bWidth;
+ bullet.mapY += sHeight / 2 - bHeight;
+
+ bullet.deltaX = -8;
+ bullet.deltaY = 0;
+ break;
+
+ case Submarine::kDirectionNW:
+ bullet.mapX -= bWidth;
+ bullet.mapY -= bHeight;
+
+ bullet.deltaX = -8;
+ bullet.deltaY = -8;
+ break;
+
+ default:
+ break;
+ }
+}
+
+uint16 Penetration::directionToBullet(Submarine::Direction direction) const {
+ switch (direction) {
+ case Submarine::kDirectionN:
+ return kSpriteBulletN;
+
+ case Submarine::kDirectionNE:
+ return kSpriteBulletNE;
+
+ case Submarine::kDirectionE:
+ return kSpriteBulletE;
+
+ case Submarine::kDirectionSE:
+ return kSpriteBulletSE;
+
+ case Submarine::kDirectionS:
+ return kSpriteBulletS;
+
+ case Submarine::kDirectionSW:
+ return kSpriteBulletSW;
+
+ case Submarine::kDirectionW:
+ return kSpriteBulletW;
+
+ case Submarine::kDirectionNW:
+ return kSpriteBulletNW;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+int Penetration::findEmptyBulletSlot() const {
+ for (int i = 0; i < kMaxBulletCount; i++)
+ if (!_bullets[i].bullet->isVisible())
+ return i;
+
+ return -1;
+}
+
+void Penetration::bulletsMove() {
+ for (int i = 0; i < kMaxBulletCount; i++)
+ if (_bullets[i].bullet->isVisible())
+ bulletMove(_bullets[i]);
+}
+
+void Penetration::bulletMove(ManagedBullet &bullet) {
+ MapObject *blockedBy;
+ findPath(bullet, bullet.deltaX, bullet.deltaY, &blockedBy);
+
+ if (blockedBy) {
+ checkShotEnemy(*blockedBy);
+ bullet.bullet->setVisible(false);
+ return;
+ }
+
+ const int posX = kPlayAreaBorderWidth + bullet.mapX;
+ const int posY = kPlayAreaBorderHeight + bullet.mapY;
+
+ bullet.bullet->setPosition(posX, posY);
+}
+
+void Penetration::checkShotEnemy(MapObject &shotObject) {
+ for (int i = 0; i < kEnemyCount; i++) {
+ ManagedEnemy &enemy = _enemies[i];
+
+ if ((&enemy == &shotObject) && !enemy.dead && enemy.enemy->isVisible()) {
+ enemyExplode(enemy);
+ return;
+ }
+ }
+}
+
+Submarine::Direction Penetration::getDirection(int &x, int &y) const {
+ x = _keys[kKeyRight] ? 3 : (_keys[kKeyLeft] ? -3 : 0);
+ y = _keys[kKeyDown ] ? 3 : (_keys[kKeyUp ] ? -3 : 0);
+
+ if ((x > 0) && (y > 0))
+ return Submarine::kDirectionSE;
+ if ((x > 0) && (y < 0))
+ return Submarine::kDirectionNE;
+ if ((x < 0) && (y > 0))
+ return Submarine::kDirectionSW;
+ if ((x < 0) && (y < 0))
+ return Submarine::kDirectionNW;
+ if (x > 0)
+ return Submarine::kDirectionE;
+ if (x < 0)
+ return Submarine::kDirectionW;
+ if (y > 0)
+ return Submarine::kDirectionS;
+ if (y < 0)
+ return Submarine::kDirectionN;
+
+ return Submarine::kDirectionNone;
+}
+
+void Penetration::checkShields() {
+ for (Common::List<MapObject>::iterator s = _shields.begin(); s != _shields.end(); ++s) {
+ if ((s->tileX == _sub->tileX) && (s->tileY == _sub->tileY)) {
+ // Charge shields
+ _shieldMeter->setMaxValue();
+
+ // Play the shield sound
+ _vm->_sound->blasterPlay(&_soundShield, 1, 0);
+
+ // Erase the shield from the map
+ _sprites->draw(*_map, 30, s->mapX + kPlayAreaBorderWidth, s->mapY + kPlayAreaBorderHeight);
+ _shields.erase(s);
+ break;
+ }
+ }
+}
+
+void Penetration::checkMouths() {
+ for (Common::List<ManagedMouth>::iterator m = _mouths.begin(); m != _mouths.end(); ++m) {
+ if (!m->mouth->isDeactivated())
+ continue;
+
+ if ((( m->tileX == _sub->tileX) && (m->tileY == _sub->tileY)) ||
+ (((m->tileX + 1) == _sub->tileX) && (m->tileY == _sub->tileY))) {
+
+ m->mouth->activate();
+
+ // Play the mouth sound and do health gain/loss
+ if (m->type == kMouthTypeBite) {
+ _vm->_sound->blasterPlay(&_soundBite, 1, 0);
+ healthLose(230);
+ } else if (m->type == kMouthTypeKiss) {
+ _vm->_sound->blasterPlay(&_soundKiss, 1, 0);
+ healthGain(120);
+ }
+ }
+ }
+}
+
+void Penetration::checkExits() {
+ if (!_sub->sub->canMove())
+ return;
+
+ for (Common::List<MapObject>::iterator e = _exits.begin(); e != _exits.end(); ++e) {
+ if ((e->tileX == _sub->tileX) && (e->tileY == _sub->tileY)) {
+ _sub->setMapFromTilePosition();
+
+ _sub->sub->leave();
+
+ _vm->_sound->blasterPlay(&_soundExit, 1, 0);
+ break;
+ }
+ }
+}
+
+void Penetration::healthGain(int amount) {
+ if (_shieldMeter->getValue() > 0)
+ _healthMeter->increase(_shieldMeter->increase(amount));
+ else
+ _healthMeter->increase(amount);
+}
+
+void Penetration::healthLose(int amount) {
+ _healthMeter->decrease(_shieldMeter->decrease(amount));
+
+ if (_healthMeter->getValue() == 0)
+ _sub->sub->die();
+}
+
+void Penetration::checkExited() {
+ if (_sub->sub->hasExited()) {
+ _floor++;
+
+ if (_floor >= kFloorCount)
+ return;
+
+ setPalette();
+ createMap();
+ drawFloorText();
+ }
+}
+
+bool Penetration::isDead() const {
+ return _sub && _sub->sub->isDead();
+}
+
+bool Penetration::hasWon() const {
+ return _floor >= kFloorCount;
+}
+
+int Penetration::getLanguage() const {
+ if (_vm->_global->_language < kLanguageCount)
+ return _vm->_global->_language;
+
+ return kFallbackLanguage;
+}
+
+void Penetration::updateAnims() {
+ int16 left = 0, top = 0, right = 0, bottom = 0;
+
+ // Clear the previous map animation frames
+ for (Common::List<ANIObject *>::iterator a = _mapAnims.reverse_begin();
+ a != _mapAnims.end(); --a) {
+
+ (*a)->clear(*_map, left, top, right, bottom);
+ }
+
+ // Draw the current map animation frames
+ for (Common::List<ANIObject *>::iterator a = _mapAnims.begin();
+ a != _mapAnims.end(); ++a) {
+
+ (*a)->draw(*_map, left, top, right, bottom);
+ (*a)->advance();
+ }
+
+ // Clear the previous animation frames
+ for (Common::List<ANIObject *>::iterator a = _anims.reverse_begin();
+ a != _anims.end(); --a) {
+
+ if ((*a)->clear(*_vm->_draw->_backSurface, left, top, right, bottom))
+ _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom);
+ }
+
+ if (_sub) {
+ // Draw the map
+
+ _vm->_draw->_backSurface->blit(*_map, _sub->mapX, _sub->mapY,
+ _sub->mapX + kPlayAreaWidth - 1, _sub->mapY + kPlayAreaHeight - 1, kPlayAreaX, kPlayAreaY);
+ _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, kPlayAreaX, kPlayAreaY,
+ kPlayAreaX + kPlayAreaWidth - 1, kPlayAreaY + kPlayAreaHeight - 1);
+ }
+
+ // Draw the current animation frames
+ for (Common::List<ANIObject *>::iterator a = _anims.begin();
+ a != _anims.end(); ++a) {
+
+ if ((*a)->draw(*_vm->_draw->_backSurface, left, top, right, bottom))
+ _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom);
+
+ (*a)->advance();
+ }
+
+ // Draw the meters
+ _shieldMeter->draw(*_vm->_draw->_backSurface, left, top, right, bottom);
+ _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom);
+
+ _healthMeter->draw(*_vm->_draw->_backSurface, left, top, right, bottom);
+ _vm->_draw->dirtiedRect(_vm->_draw->_backSurface, left, top, right, bottom);
+}
+
} // End of namespace Geisha
} // End of namespace Gob
diff --git a/engines/gob/minigames/geisha/penetration.h b/engines/gob/minigames/geisha/penetration.h
index c346a7bf5a..50004eba8e 100644
--- a/engines/gob/minigames/geisha/penetration.h
+++ b/engines/gob/minigames/geisha/penetration.h
@@ -24,34 +24,229 @@
#define GOB_MINIGAMES_GEISHA_PENETRATION_H
#include "common/system.h"
+#include "common/list.h"
+
+#include "gob/sound/sounddesc.h"
+
+#include "gob/minigames/geisha/submarine.h"
namespace Gob {
class GobEngine;
class Surface;
+class CMPFile;
class ANIFile;
namespace Geisha {
+class Meter;
+class Mouth;
+
/** Geisha's "Penetration" minigame. */
class Penetration {
public:
Penetration(GobEngine *vm);
~Penetration();
- bool play(uint16 var1, uint16 var2, uint16 var3);
+ bool play(bool hasAccessPass, bool hasMaxEnergy, bool testMode);
+
+ bool isPlaying() const;
+ void cheatWin();
private:
+ static const int kModeCount = 2;
+ static const int kFloorCount = 3;
+
+ static const int kMapWidth = 17;
+ static const int kMapHeight = 13;
+
+ static const int kPaletteSize = 16;
+
+ static const byte kPalettes[kFloorCount][3 * kPaletteSize];
+ static const byte kMaps[kModeCount][kFloorCount][kMapWidth * kMapHeight];
+
+ static const int kEnemyCount = 9;
+ static const int kMaxBulletCount = 10;
+
+ struct MapObject {
+ uint16 tileX;
+ uint16 tileY;
+
+ uint16 mapX;
+ uint16 mapY;
+
+ uint16 width;
+ uint16 height;
+
+ bool isBlocking;
+
+ MapObject(uint16 tX, uint16 tY, uint16 mX, uint16 mY, uint16 w, uint16 h);
+ MapObject(uint16 tX, uint16 tY, uint16 w, uint16 h);
+
+ void setTileFromMapPosition();
+ void setMapFromTilePosition();
+
+ bool isIn(uint16 mX, uint16 mY) const;
+ bool isIn(uint16 mX, uint16 mY, uint16 w, uint16 h) const;
+ bool isIn(const MapObject &obj) const;
+ };
+
+ enum MouthType {
+ kMouthTypeBite,
+ kMouthTypeKiss
+ };
+
+ struct ManagedMouth : public MapObject {
+ Mouth *mouth;
+
+ MouthType type;
+
+ ManagedMouth(uint16 tX, uint16 tY, MouthType t);
+ ~ManagedMouth();
+ };
+
+ struct ManagedSub : public MapObject {
+ Submarine *sub;
+
+ ManagedSub(uint16 tX, uint16 tY);
+ ~ManagedSub();
+ };
+
+ struct ManagedEnemy : public MapObject {
+ ANIObject *enemy;
+
+ bool dead;
+
+ ManagedEnemy();
+ ~ManagedEnemy();
+
+ void clear();
+ };
+
+ struct ManagedBullet : public MapObject {
+ ANIObject *bullet;
+
+ int16 deltaX;
+ int16 deltaY;
+
+ ManagedBullet();
+ ~ManagedBullet();
+
+ void clear();
+ };
+
+ enum Keys {
+ kKeyUp = 0,
+ kKeyDown,
+ kKeyLeft,
+ kKeyRight,
+ kKeySpace,
+ kKeyCount
+ };
+
GobEngine *_vm;
+ bool _hasAccessPass;
+ bool _hasMaxEnergy;
+ bool _testMode;
+
+ bool _needFadeIn;
+
+ bool _quit;
+ bool _keys[kKeyCount];
+
Surface *_background;
+ CMPFile *_sprites;
ANIFile *_objects;
+ Common::List<ANIObject *> _anims;
+ Common::List<ANIObject *> _mapAnims;
+
+ Meter *_shieldMeter;
+ Meter *_healthMeter;
+
+ uint8 _floor;
+
+ Surface *_map;
+
+ ManagedSub *_sub;
+
+ Common::List<MapObject> _walls;
+ Common::List<MapObject> _exits;
+ Common::List<MapObject> _shields;
+ Common::List<ManagedMouth> _mouths;
+
+ ManagedEnemy _enemies[kEnemyCount];
+ ManagedBullet _bullets[kMaxBulletCount];
+
+ Common::List<MapObject *> _blockingObjects;
+
+ uint8 _shotCoolDown;
+
+ SoundDesc _soundShield;
+ SoundDesc _soundBite;
+ SoundDesc _soundKiss;
+ SoundDesc _soundShoot;
+ SoundDesc _soundExit;
+ SoundDesc _soundExplode;
+
+ bool _isPlaying;
+
void init();
void deinit();
+ void clearMap();
+ void createMap();
+
void initScreen();
+
+ void setPalette();
+ void fadeIn();
+
+ void drawFloorText();
+ void drawEndText();
+
+ bool isBlocked(const MapObject &self, int16 x, int16 y, MapObject **blockedBy = 0);
+ void findPath(MapObject &obj, int x, int y, MapObject **blockedBy = 0);
+
+ void updateAnims();
+
+ void checkInput();
+
+ Submarine::Direction getDirection(int &x, int &y) const;
+
+ void handleSub();
+ void subMove(int x, int y, Submarine::Direction direction);
+ void subShoot();
+
+ int findEmptyBulletSlot() const;
+ uint16 directionToBullet(Submarine::Direction direction) const;
+ void setBulletPosition(const ManagedSub &sub, ManagedBullet &bullet) const;
+
+ void bulletsMove();
+ void bulletMove(ManagedBullet &bullet);
+ void checkShotEnemy(MapObject &shotObject);
+
+ void checkExits();
+ void checkShields();
+ void checkMouths();
+
+ void healthGain(int amount);
+ void healthLose(int amount);
+
+ void checkExited();
+
+ void enemiesCreate();
+ void enemiesMove();
+ void enemyMove(ManagedEnemy &enemy, int x, int y);
+ void enemyAttack(ManagedEnemy &enemy);
+ void enemyExplode(ManagedEnemy &enemy);
+
+ bool isDead() const;
+ bool hasWon() const;
+
+ int getLanguage() const;
};
} // End of namespace Geisha
diff --git a/engines/gob/minigames/geisha/submarine.cpp b/engines/gob/minigames/geisha/submarine.cpp
new file mode 100644
index 0000000000..bf15306e5a
--- /dev/null
+++ b/engines/gob/minigames/geisha/submarine.cpp
@@ -0,0 +1,256 @@
+/* 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/submarine.h"
+
+namespace Gob {
+
+namespace Geisha {
+
+enum Animation {
+ kAnimationDriveS = 4,
+ kAnimationDriveE = 5,
+ kAnimationDriveN = 6,
+ kAnimationDriveW = 7,
+ kAnimationDriveSE = 8,
+ kAnimationDriveNE = 9,
+ kAnimationDriveSW = 10,
+ kAnimationDriveNW = 11,
+ kAnimationShootS = 12,
+ kAnimationShootN = 13,
+ kAnimationShootW = 14,
+ kAnimationShootE = 15,
+ kAnimationShootNE = 16,
+ kAnimationShootSE = 17,
+ kAnimationShootSW = 18,
+ kAnimationShootNW = 19,
+ kAnimationExplodeN = 28,
+ kAnimationExplodeS = 29,
+ kAnimationExplodeW = 30,
+ kAnimationExplodeE = 31,
+ kAnimationExit = 32
+};
+
+
+Submarine::Submarine(const ANIFile &ani) : ANIObject(ani), _state(kStateMove), _direction(kDirectionNone) {
+ turn(kDirectionN);
+}
+
+Submarine::~Submarine() {
+}
+
+Submarine::Direction Submarine::getDirection() const {
+ return _direction;
+}
+
+void Submarine::turn(Direction to) {
+ // Nothing to do
+ if ((to == kDirectionNone) || ((_state == kStateMove) && (_direction == to)))
+ return;
+
+ _direction = to;
+
+ move();
+}
+
+void Submarine::move() {
+ uint16 frame = getFrame();
+ uint16 anim = (_state == kStateShoot) ? directionToShoot(_direction) : directionToMove(_direction);
+
+ setAnimation(anim);
+ setFrame(frame);
+ setPause(false);
+ setVisible(true);
+
+ setMode((_state == kStateShoot) ? kModeOnce : kModeContinuous);
+}
+
+void Submarine::shoot() {
+ _state = kStateShoot;
+
+ setAnimation(directionToShoot(_direction));
+ setMode(kModeOnce);
+ setPause(false);
+ setVisible(true);
+}
+
+void Submarine::die() {
+ if (!canMove())
+ return;
+
+ _state = kStateDie;
+
+ setAnimation(directionToExplode(_direction));
+ setMode(kModeOnce);
+ setPause(false);
+ setVisible(true);
+}
+
+void Submarine::leave() {
+ _state = kStateExit;
+
+ setAnimation(kAnimationExit);
+ setMode(kModeOnce);
+ setPause(false);
+ setVisible(true);
+}
+
+void Submarine::advance() {
+ ANIObject::advance();
+
+ switch (_state) {
+ case kStateShoot:
+ if (isPaused()) {
+ _state = kStateMove;
+
+ move();
+ }
+ break;
+
+ case kStateExit:
+ if (isPaused())
+ _state = kStateExited;
+
+ break;
+
+ case kStateDie:
+ if (isPaused())
+ _state = kStateDead;
+ break;
+
+ default:
+ break;
+ }
+}
+
+bool Submarine::canMove() const {
+ return (_state == kStateMove) || (_state == kStateShoot);
+}
+
+bool Submarine::isDead() const {
+ return _state == kStateDead;
+}
+
+bool Submarine::isShooting() const {
+ return _state == kStateShoot;
+}
+
+bool Submarine::hasExited() const {
+ return _state == kStateExited;
+}
+
+uint16 Submarine::directionToMove(Direction direction) const {
+ switch (direction) {
+ case kDirectionN:
+ return kAnimationDriveN;
+
+ case kDirectionNE:
+ return kAnimationDriveNE;
+
+ case kDirectionE:
+ return kAnimationDriveE;
+
+ case kDirectionSE:
+ return kAnimationDriveSE;
+
+ case kDirectionS:
+ return kAnimationDriveS;
+
+ case kDirectionSW:
+ return kAnimationDriveSW;
+
+ case kDirectionW:
+ return kAnimationDriveW;
+
+ case kDirectionNW:
+ return kAnimationDriveNW;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+uint16 Submarine::directionToShoot(Direction direction) const {
+ switch (direction) {
+ case kDirectionN:
+ return kAnimationShootN;
+
+ case kDirectionNE:
+ return kAnimationShootNE;
+
+ case kDirectionE:
+ return kAnimationShootE;
+
+ case kDirectionSE:
+ return kAnimationShootSE;
+
+ case kDirectionS:
+ return kAnimationShootS;
+
+ case kDirectionSW:
+ return kAnimationShootSW;
+
+ case kDirectionW:
+ return kAnimationShootW;
+
+ case kDirectionNW:
+ return kAnimationShootNW;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+uint16 Submarine::directionToExplode(Direction direction) const {
+ // Only 4 exploding animations (spinning clockwise)
+
+ switch (direction) {
+ case kDirectionNW:
+ case kDirectionN:
+ return kAnimationExplodeN;
+
+ case kDirectionNE:
+ case kDirectionE:
+ return kAnimationExplodeE;
+
+ case kDirectionSE:
+ case kDirectionS:
+ return kAnimationExplodeS;
+
+ case kDirectionSW:
+ case kDirectionW:
+ return kAnimationExplodeW;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+} // End of namespace Geisha
+
+} // End of namespace Gob
diff --git a/engines/gob/minigames/geisha/submarine.h b/engines/gob/minigames/geisha/submarine.h
new file mode 100644
index 0000000000..a6eae57095
--- /dev/null
+++ b/engines/gob/minigames/geisha/submarine.h
@@ -0,0 +1,107 @@
+/* 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_SUBMARINE_H
+#define GOB_MINIGAMES_GEISHA_SUBMARINE_H
+
+#include "gob/aniobject.h"
+
+namespace Gob {
+
+namespace Geisha {
+
+/** The submarine Geisha's "Penetration" minigame. */
+class Submarine : public ANIObject {
+public:
+ enum Direction {
+ kDirectionNone,
+ kDirectionN,
+ kDirectionNE,
+ kDirectionE,
+ kDirectionSE,
+ kDirectionS,
+ kDirectionSW,
+ kDirectionW,
+ kDirectionNW
+ };
+
+ Submarine(const ANIFile &ani);
+ ~Submarine();
+
+ Direction getDirection() const;
+
+ /** Turn to the specified direction. */
+ void turn(Direction to);
+
+ /** Play the shoot animation. */
+ void shoot();
+
+ /** Play the exploding animation. */
+ void die();
+
+ /** Play the exiting animation. */
+ void leave();
+
+ /** Advance the animation to the next frame. */
+ void advance();
+
+ /** Can the submarine move at the moment? */
+ bool canMove() const;
+
+ /** Is the submarine dead? */
+ bool isDead() const;
+
+ /** Is the submarine shooting? */
+ bool isShooting() const;
+
+ /** Has the submarine finished exiting the level? */
+ bool hasExited() const;
+
+private:
+ enum State {
+ kStateNone = 0,
+ kStateMove,
+ kStateShoot,
+ kStateExit,
+ kStateExited,
+ kStateDie,
+ kStateDead
+ };
+
+ State _state;
+ Direction _direction;
+
+ /** Map the directions to move animation indices. */
+ uint16 directionToMove(Direction direction) const;
+ /** Map the directions to shoot animation indices. */
+ uint16 directionToShoot(Direction direction) const;
+ /** Map the directions to explode animation indices. */
+ uint16 directionToExplode(Direction direction) const;
+
+ void move();
+};
+
+} // End of namespace Geisha
+
+} // End of namespace Gob
+
+#endif // GOB_MINIGAMES_GEISHA_SUBMARINE_H