[Scummvm-cvs-logs] scummvm master -> 5caf4ac4003180bcbf897d6bfa1812eba8d5e76c

DrMcCoy drmccoy at drmccoy.de
Wed Sep 14 19:05:48 CEST 2011


This automated email contains information about 8 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
96961b2c2d GOB: More const correctness
918fe978e2 GOB: Add ANIObject::setPause()
358f55db40 GOB: Add stubby "Diving" black pearl drawing
00a5ccfce0 GOB: Add stubby "Diving" white pearl drawing
ac3593c631 GOB: Init "Diving" cursor
a43794b9c4 GOB: Add ANIObject animation mode
e21b1af568 GOB: Add ANIObject::rewind()
5caf4ac400 GOB: Implement the fish shooting part of the Diving minigame


Commit: 96961b2c2d8fff0fe4d4b093000e02dc6147aecf
    https://github.com/scummvm/scummvm/commit/96961b2c2d8fff0fe4d4b093000e02dc6147aecf
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2011-09-14T09:54:27-07:00

Commit Message:
GOB: More const correctness

Changed paths:
    engines/gob/minigames/geisha/penetration.cpp



diff --git a/engines/gob/minigames/geisha/penetration.cpp b/engines/gob/minigames/geisha/penetration.cpp
index 4334cae..121a45b 100644
--- a/engines/gob/minigames/geisha/penetration.cpp
+++ b/engines/gob/minigames/geisha/penetration.cpp
@@ -33,7 +33,7 @@ namespace Gob {
 
 namespace Geisha {
 
-static byte kPalette[48] = {
+static const byte kPalette[48] = {
 	0x16,  0x16,  0x16,
 	0x12,  0x14,  0x16,
 	0x34,  0x00,  0x25,


Commit: 918fe978e2d4f1e149cf8040e087b7b70e54c9d4
    https://github.com/scummvm/scummvm/commit/918fe978e2d4f1e149cf8040e087b7b70e54c9d4
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2011-09-14T09:54:27-07:00

Commit Message:
GOB: Add ANIObject::setPause()

Changed paths:
    engines/gob/aniobject.cpp
    engines/gob/aniobject.h
    engines/gob/minigames/geisha/diving.cpp



diff --git a/engines/gob/aniobject.cpp b/engines/gob/aniobject.cpp
index c6a9234..9974874 100644
--- a/engines/gob/aniobject.cpp
+++ b/engines/gob/aniobject.cpp
@@ -26,8 +26,8 @@
 
 namespace Gob {
 
-ANIObject::ANIObject(const ANIFile &ani) : _ani(&ani), _visible(false),
-	_x(0), _y(0), _background(0), _drawn(false) {
+ANIObject::ANIObject(const ANIFile &ani) : _ani(&ani),
+	_visible(false), _paused(false), _x(0), _y(0), _background(0), _drawn(false) {
 
 	setAnimation(0);
 	setPosition();
@@ -45,6 +45,14 @@ bool ANIObject::isVisible() const {
 	return _visible;
 }
 
+void ANIObject::setPause(bool pause) {
+	_paused = pause;
+}
+
+bool ANIObject::isPaused() const {
+	return _paused;
+}
+
 void ANIObject::setAnimation(uint16 animation) {
 	_animation = animation;
 	_frame     = 0;
@@ -152,6 +160,9 @@ void ANIObject::clear(Surface &dest, int16 &left, int16 &top,
 }
 
 void ANIObject::advance() {
+	if (_paused)
+		return;
+
 	if (_animation >= _ani->getAnimationCount())
 		return;
 
diff --git a/engines/gob/aniobject.h b/engines/gob/aniobject.h
index 357c2a9..c5352dd 100644
--- a/engines/gob/aniobject.h
+++ b/engines/gob/aniobject.h
@@ -42,6 +42,12 @@ public:
 	/** Is the object currently visible? */
 	bool isVisible() const;
 
+	/** Pause/Unpause the animation. */
+	void setPause(bool pause);
+
+	/** Is the animation currently paused? */
+	bool isPaused() const;
+
 	/** Set the current position to the animation's default. */
 	void setPosition();
 	/** Set the current position. */
@@ -81,6 +87,7 @@ private:
 	uint16 _frame;     ///< The current frame.
 
 	bool _visible; ///< Is the object currently visible?
+	bool _paused;  ///< Is the animation currently paused?
 
 	int16 _x; ///< The current X position.
 	int16 _y; ///< The current Y position.
diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp
index 0d216ab..6130eba 100644
--- a/engines/gob/minigames/geisha/diving.cpp
+++ b/engines/gob/minigames/geisha/diving.cpp
@@ -58,6 +58,8 @@ bool Diving::play(uint16 playerCount, bool hasPearlLocation) {
 
 	objects.push_back(_water);
 	objects.push_back(&shark);
+	objects.push_back(_lungs);
+	objects.push_back(_heart);
 
 	shark.enter(EvilFish::kDirectionLeft, 90);
 
@@ -109,10 +111,12 @@ void Diving::init() {
 	_lungs->setAnimation(0);
 	_lungs->setPosition();
 	_lungs->setVisible(true);
+	_lungs->setPause(true);
 
 	_heart->setAnimation(1);
 	_heart->setPosition();
 	_heart->setVisible(true);
+	_heart->setPause(true);
 }
 
 void Diving::deinit() {


Commit: 358f55db402d1c8acd72c65f76b37a310575809d
    https://github.com/scummvm/scummvm/commit/358f55db402d1c8acd72c65f76b37a310575809d
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2011-09-14T09:54:27-07:00

Commit Message:
GOB: Add stubby "Diving" black pearl drawing

Changed paths:
    engines/gob/minigames/geisha/diving.cpp
    engines/gob/minigames/geisha/diving.h



diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp
index 6130eba..d2f51e6 100644
--- a/engines/gob/minigames/geisha/diving.cpp
+++ b/engines/gob/minigames/geisha/diving.cpp
@@ -37,11 +37,15 @@ namespace Gob {
 namespace Geisha {
 
 Diving::Diving(GobEngine *vm) : _vm(vm), _background(0),
-	_objects(0), _gui(0), _oko(0), _lungs(0), _heart(0) {
+	_objects(0), _gui(0), _oko(0), _lungs(0), _heart(0),
+	_blackPearl(0), _blackPearlCount(0) {
 
+	_blackPearl = new Surface(11, 8, 1);
 }
 
 Diving::~Diving() {
+	delete _blackPearl;
+
 	deinit();
 }
 
@@ -88,10 +92,13 @@ bool Diving::play(uint16 playerCount, bool hasPearlLocation) {
 
 		_vm->_util->waitEndFrame();
 		_vm->_util->processInput();
+
+		if (_blackPearlCount >= 2)
+			break;
 	}
 
 	deinit();
-	return true;
+	return _blackPearlCount >= 2;
 }
 
 void Diving::init() {
@@ -117,6 +124,14 @@ void Diving::init() {
 	_heart->setPosition();
 	_heart->setVisible(true);
 	_heart->setPause(true);
+
+	Surface tmp(320, 103, 1);
+
+	_vm->_video->drawPackedSprite("tperlobj.cmp", tmp);
+
+	_blackPearl->blit(tmp, 282, 80, 292, 87, 0, 0);
+
+	_blackPearlCount = 0;
 }
 
 void Diving::deinit() {
@@ -154,6 +169,18 @@ void Diving::initScreen() {
 	_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 0, 0, 319, 199);
 }
 
+void Diving::foundBlackPearl() {
+	_blackPearlCount++;
+
+	if        (_blackPearlCount == 1) {
+		_vm->_draw->_backSurface->blit(*_blackPearl, 0, 0, 10, 7, 147, 179, 0);
+		_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 147, 179, 157, 186);
+	} else if (_blackPearlCount == 2) {
+		_vm->_draw->_backSurface->blit(*_blackPearl, 0, 0, 10, 7, 160, 179, 0);
+		_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 147, 179, 160, 186);
+	}
+}
+
 } // End of namespace Geisha
 
 } // End of namespace Gob
diff --git a/engines/gob/minigames/geisha/diving.h b/engines/gob/minigames/geisha/diving.h
index 238a1ad..96a8a74 100644
--- a/engines/gob/minigames/geisha/diving.h
+++ b/engines/gob/minigames/geisha/diving.h
@@ -28,6 +28,7 @@
 namespace Gob {
 
 class GobEngine;
+class Surface;
 class DECFile;
 class ANIFile;
 class ANIObject;
@@ -54,11 +55,16 @@ private:
 	ANIObject *_lungs;
 	ANIObject *_heart;
 
+	Surface *_blackPearl;
+
+	uint8 _blackPearlCount;
 
 	void init();
 	void deinit();
 
 	void initScreen();
+
+	void foundBlackPearl();
 };
 
 } // End of namespace Geisha


Commit: 00a5ccfce09d02e55515ef9e0e25a7e7b1f74c39
    https://github.com/scummvm/scummvm/commit/00a5ccfce09d02e55515ef9e0e25a7e7b1f74c39
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2011-09-14T09:54:28-07:00

Commit Message:
GOB: Add stubby "Diving" white pearl drawing

Changed paths:
    engines/gob/minigames/geisha/diving.cpp
    engines/gob/minigames/geisha/diving.h



diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp
index d2f51e6..c3a8a30 100644
--- a/engines/gob/minigames/geisha/diving.cpp
+++ b/engines/gob/minigames/geisha/diving.cpp
@@ -38,7 +38,7 @@ namespace Geisha {
 
 Diving::Diving(GobEngine *vm) : _vm(vm), _background(0),
 	_objects(0), _gui(0), _oko(0), _lungs(0), _heart(0),
-	_blackPearl(0), _blackPearlCount(0) {
+	_blackPearl(0), _whitePearlCount(0), _blackPearlCount(0) {
 
 	_blackPearl = new Surface(11, 8, 1);
 }
@@ -93,7 +93,7 @@ bool Diving::play(uint16 playerCount, bool hasPearlLocation) {
 		_vm->_util->waitEndFrame();
 		_vm->_util->processInput();
 
-		if (_blackPearlCount >= 2)
+		if ((_whitePearlCount >= 20) || (_blackPearlCount >= 2))
 			break;
 	}
 
@@ -181,6 +181,17 @@ void Diving::foundBlackPearl() {
 	}
 }
 
+void Diving::foundWhitePearl() {
+	_whitePearlCount++;
+
+	int16 x = 54 + (_whitePearlCount - 1) * 8;
+	if (_whitePearlCount > 10)
+		x += 48;
+
+	_background->drawLayer(*_vm->_draw->_backSurface, 0, 2, x, 177, 0);
+	_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, x, 177, x + 3, 180);
+}
+
 } // End of namespace Geisha
 
 } // End of namespace Gob
diff --git a/engines/gob/minigames/geisha/diving.h b/engines/gob/minigames/geisha/diving.h
index 96a8a74..9975b0f 100644
--- a/engines/gob/minigames/geisha/diving.h
+++ b/engines/gob/minigames/geisha/diving.h
@@ -57,6 +57,7 @@ private:
 
 	Surface *_blackPearl;
 
+	uint8 _whitePearlCount;
 	uint8 _blackPearlCount;
 
 	void init();
@@ -65,6 +66,7 @@ private:
 	void initScreen();
 
 	void foundBlackPearl();
+	void foundWhitePearl();
 };
 
 } // End of namespace Geisha


Commit: ac3593c63143e7bea9dfab6b237a812186c9dcee
    https://github.com/scummvm/scummvm/commit/ac3593c63143e7bea9dfab6b237a812186c9dcee
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2011-09-14T09:54:28-07:00

Commit Message:
GOB: Init "Diving" cursor

Changed paths:
    engines/gob/draw.cpp
    engines/gob/draw.h
    engines/gob/draw_v1.cpp
    engines/gob/draw_v2.cpp
    engines/gob/minigames/geisha/diving.cpp
    engines/gob/minigames/geisha/diving.h



diff --git a/engines/gob/draw.cpp b/engines/gob/draw.cpp
index 5806965..4b659f5 100644
--- a/engines/gob/draw.cpp
+++ b/engines/gob/draw.cpp
@@ -107,6 +107,9 @@ Draw::Draw(GobEngine *vm) : _vm(vm) {
 	_cursorHotspotXVar = -1;
 	_cursorHotspotYVar = -1;
 
+	_cursorHotspotX = -1;
+	_cursorHotspotY = -1;
+
 	_cursorAnim = 0;
 	for (int i = 0; i < 40; i++) {
 		_cursorAnimLow[i] = 0;
diff --git a/engines/gob/draw.h b/engines/gob/draw.h
index 57faefa..393822c 100644
--- a/engines/gob/draw.h
+++ b/engines/gob/draw.h
@@ -133,6 +133,9 @@ public:
 	int32 _cursorHotspotXVar;
 	int32 _cursorHotspotYVar;
 
+	int32 _cursorHotspotX;
+	int32 _cursorHotspotY;
+
 	SurfacePtr _cursorSprites;
 	SurfacePtr _cursorSpritesBack;
 	SurfacePtr _scummvmCursor;
diff --git a/engines/gob/draw_v1.cpp b/engines/gob/draw_v1.cpp
index 064c749..8cb88b5 100644
--- a/engines/gob/draw_v1.cpp
+++ b/engines/gob/draw_v1.cpp
@@ -112,6 +112,9 @@ void Draw_v1::animateCursor(int16 cursor) {
 		if (_cursorHotspotXVar != -1) {
 			newX -= hotspotX = (uint16) VAR(_cursorIndex + _cursorHotspotXVar);
 			newY -= hotspotY = (uint16) VAR(_cursorIndex + _cursorHotspotYVar);
+		} else if (_cursorHotspotX != -1) {
+			newX -= hotspotX = _cursorHotspotX;
+			newY -= hotspotY = _cursorHotspotY;
 		}
 
 		_scummvmCursor->clear();
diff --git a/engines/gob/draw_v2.cpp b/engines/gob/draw_v2.cpp
index 151ed42..6e64d6f 100644
--- a/engines/gob/draw_v2.cpp
+++ b/engines/gob/draw_v2.cpp
@@ -138,6 +138,9 @@ void Draw_v2::animateCursor(int16 cursor) {
 		if (_cursorHotspotXVar != -1) {
 			newX -= hotspotX = (uint16) VAR(_cursorIndex + _cursorHotspotXVar);
 			newY -= hotspotY = (uint16) VAR(_cursorIndex + _cursorHotspotYVar);
+		} else if (_cursorHotspotX != -1) {
+			newX -= hotspotX = _cursorHotspotX;
+			newY -= hotspotY = _cursorHotspotY;
 		}
 
 		_scummvmCursor->clear();
diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp
index c3a8a30..f0eae32 100644
--- a/engines/gob/minigames/geisha/diving.cpp
+++ b/engines/gob/minigames/geisha/diving.cpp
@@ -52,6 +52,7 @@ Diving::~Diving() {
 bool Diving::play(uint16 playerCount, bool hasPearlLocation) {
 	init();
 	initScreen();
+	initCursor();
 
 	_vm->_draw->blitInvalidated();
 	_vm->_video->retrace();
@@ -88,6 +89,8 @@ bool Diving::play(uint16 playerCount, bool hasPearlLocation) {
 			(*o)->advance();
 		}
 
+		_vm->_draw->animateCursor(1);
+
 		_vm->_draw->blitInvalidated();
 
 		_vm->_util->waitEndFrame();
@@ -135,6 +138,9 @@ void Diving::init() {
 }
 
 void Diving::deinit() {
+	_vm->_draw->_cursorHotspotX = -1;
+	_vm->_draw->_cursorHotspotY = -1;
+
 	delete _heart;
 	delete _lungs;
 	delete _water;
@@ -169,6 +175,23 @@ void Diving::initScreen() {
 	_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 0, 0, 319, 199);
 }
 
+void Diving::initCursor() {
+	const int index = _vm->_draw->_cursorIndex;
+
+	const int16 left   = index * _vm->_draw->_cursorWidth;
+	const int16 top    = 0;
+	const int16 right  = left + _vm->_draw->_cursorWidth - 1;
+	const int16 bottom = _vm->_draw->_cursorHeight - 1;
+
+	_vm->_draw->_cursorSprites->fillRect(left, top, right, bottom, 0);
+
+	_objects->draw(*_vm->_draw->_cursorSprites, 31, 0, left, top);
+	_vm->_draw->_cursorAnimLow[index] = 0;
+
+	_vm->_draw->_cursorHotspotX = 8;
+	_vm->_draw->_cursorHotspotY = 8;
+}
+
 void Diving::foundBlackPearl() {
 	_blackPearlCount++;
 
diff --git a/engines/gob/minigames/geisha/diving.h b/engines/gob/minigames/geisha/diving.h
index 9975b0f..023ac91 100644
--- a/engines/gob/minigames/geisha/diving.h
+++ b/engines/gob/minigames/geisha/diving.h
@@ -64,6 +64,7 @@ private:
 	void deinit();
 
 	void initScreen();
+	void initCursor();
 
 	void foundBlackPearl();
 	void foundWhitePearl();


Commit: a43794b9c4e7cfd5b5bba760c08e19350c7d0c98
    https://github.com/scummvm/scummvm/commit/a43794b9c4e7cfd5b5bba760c08e19350c7d0c98
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2011-09-14T09:54:28-07:00

Commit Message:
GOB: Add ANIObject animation mode

Play the animation continuously or only once.

Changed paths:
    engines/gob/aniobject.cpp
    engines/gob/aniobject.h



diff --git a/engines/gob/aniobject.cpp b/engines/gob/aniobject.cpp
index 9974874..c689145 100644
--- a/engines/gob/aniobject.cpp
+++ b/engines/gob/aniobject.cpp
@@ -27,7 +27,8 @@
 namespace Gob {
 
 ANIObject::ANIObject(const ANIFile &ani) : _ani(&ani),
-	_visible(false), _paused(false), _x(0), _y(0), _background(0), _drawn(false) {
+	_visible(false), _paused(false), _mode(kModeContinuous),
+	_x(0), _y(0), _background(0), _drawn(false) {
 
 	setAnimation(0);
 	setPosition();
@@ -53,6 +54,10 @@ bool ANIObject::isPaused() const {
 	return _paused;
 }
 
+void ANIObject::setMode(Mode mode) {
+	_mode = mode;
+}
+
 void ANIObject::setAnimation(uint16 animation) {
 	_animation = animation;
 	_frame     = 0;
@@ -173,6 +178,11 @@ void ANIObject::advance() {
 	if (_frame == 0) {
 		_x += animation.deltaX;
 		_y += animation.deltaY;
+
+		if (_mode == kModeOnce) {
+			_paused  = true;
+			_visible = false;
+		}
 	}
 }
 
diff --git a/engines/gob/aniobject.h b/engines/gob/aniobject.h
index c5352dd..dfadf79 100644
--- a/engines/gob/aniobject.h
+++ b/engines/gob/aniobject.h
@@ -33,6 +33,11 @@ class Surface;
 /** An ANI object, controlling an animation within an ANI file. */
 class ANIObject {
 public:
+	enum Mode {
+		kModeContinuous, ///< Play the animation continuously.
+		kModeOnce        ///< Play the animation only once.
+	};
+
 	ANIObject(const ANIFile &ani);
 	virtual ~ANIObject();
 
@@ -48,6 +53,9 @@ public:
 	/** Is the animation currently paused? */
 	bool isPaused() const;
 
+	/** Set the animation mode. */
+	void setMode(Mode mode);
+
 	/** Set the current position to the animation's default. */
 	void setPosition();
 	/** Set the current position. */
@@ -89,6 +97,8 @@ private:
 	bool _visible; ///< Is the object currently visible?
 	bool _paused;  ///< Is the animation currently paused?
 
+	Mode _mode; ///< The animation mode.
+
 	int16 _x; ///< The current X position.
 	int16 _y; ///< The current Y position.
 


Commit: e21b1af568fd255da8b2a1d45b42b9d9cb170eb4
    https://github.com/scummvm/scummvm/commit/e21b1af568fd255da8b2a1d45b42b9d9cb170eb4
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2011-09-14T09:54:28-07:00

Commit Message:
GOB: Add ANIObject::rewind()

Changed paths:
    engines/gob/aniobject.cpp
    engines/gob/aniobject.h



diff --git a/engines/gob/aniobject.cpp b/engines/gob/aniobject.cpp
index c689145..a01fe43 100644
--- a/engines/gob/aniobject.cpp
+++ b/engines/gob/aniobject.cpp
@@ -63,6 +63,10 @@ void ANIObject::setAnimation(uint16 animation) {
 	_frame     = 0;
 }
 
+void ANIObject::rewind() {
+	_frame = 0;
+}
+
 void ANIObject::setPosition() {
 	if (_animation >= _ani->getAnimationCount())
 		return;
diff --git a/engines/gob/aniobject.h b/engines/gob/aniobject.h
index dfadf79..2810300 100644
--- a/engines/gob/aniobject.h
+++ b/engines/gob/aniobject.h
@@ -72,6 +72,9 @@ public:
 	/** Set the animation number. */
 	void setAnimation(uint16 animation);
 
+	/** Rewind the current animation to the first frame. */
+	void rewind();
+
 	/** Return the current animation number. */
 	uint16 getAnimation() const;
 	/** Return the current frame number. */


Commit: 5caf4ac4003180bcbf897d6bfa1812eba8d5e76c
    https://github.com/scummvm/scummvm/commit/5caf4ac4003180bcbf897d6bfa1812eba8d5e76c
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2011-09-14T09:54:28-07:00

Commit Message:
GOB: Implement the fish shooting part of the Diving minigame

Changed paths:
    engines/gob/minigames/geisha/diving.cpp
    engines/gob/minigames/geisha/diving.h
    engines/gob/minigames/geisha/evilfish.h



diff --git a/engines/gob/minigames/geisha/diving.cpp b/engines/gob/minigames/geisha/diving.cpp
index f0eae32..355edd7 100644
--- a/engines/gob/minigames/geisha/diving.cpp
+++ b/engines/gob/minigames/geisha/diving.cpp
@@ -57,37 +57,12 @@ bool Diving::play(uint16 playerCount, bool hasPearlLocation) {
 	_vm->_draw->blitInvalidated();
 	_vm->_video->retrace();
 
-	EvilFish shark(*_objects, 320, 0, 14, 8, 9, 3);
+	while (!_vm->shouldQuit()) {
+		evilFishEnter();
 
-	Common::List<ANIObject *> objects;
+		checkShots();
 
-	objects.push_back(_water);
-	objects.push_back(&shark);
-	objects.push_back(_lungs);
-	objects.push_back(_heart);
-
-	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();
-		}
+		updateAnims();
 
 		_vm->_draw->animateCursor(1);
 
@@ -96,6 +71,16 @@ bool Diving::play(uint16 playerCount, bool hasPearlLocation) {
 		_vm->_util->waitEndFrame();
 		_vm->_util->processInput();
 
+		int16 mouseX, mouseY;
+		MouseButtons mouseButtons;
+
+		int16 key = checkInput(mouseX, mouseY, mouseButtons);
+		if (key == kKeyEscape)
+			break;
+
+		if (mouseButtons == kMouseButtonsLeft)
+			shoot(mouseX, mouseY);
+
 		if ((_whitePearlCount >= 20) || (_blackPearlCount >= 2))
 			break;
 	}
@@ -128,6 +113,17 @@ void Diving::init() {
 	_heart->setVisible(true);
 	_heart->setPause(true);
 
+	_evilFish[0] = new EvilFish(*_objects, 320,  0, 14,  8,  9, 3); // Shark
+	_evilFish[1] = new EvilFish(*_objects, 320, 15,  1, 12, 13, 3); // Moray
+	_evilFish[2] = new EvilFish(*_objects, 320, 16,  2, 10, 11, 3); // Ray
+
+	for (uint i = 0; i < kMaxShotCount; i++) {
+		_shot[i] = new ANIObject(*_objects);
+
+		_shot[i]->setAnimation(17);
+		_shot[i]->setMode(ANIObject::kModeOnce);
+	}
+
 	Surface tmp(320, 103, 1);
 
 	_vm->_video->drawPackedSprite("tperlobj.cmp", tmp);
@@ -135,12 +131,38 @@ void Diving::init() {
 	_blackPearl->blit(tmp, 282, 80, 292, 87, 0, 0);
 
 	_blackPearlCount = 0;
+
+	_currentShot = 0;
+
+	_anims.push_back(_water);
+	for (uint i = 0; i < kMaxShotCount; i++)
+		_anims.push_back(_shot[i]);
+	for (uint i = 0; i < kEvilFishCount; i++)
+		_anims.push_back(_evilFish[i]);
+	_anims.push_back(_lungs);
+	_anims.push_back(_heart);
 }
 
 void Diving::deinit() {
 	_vm->_draw->_cursorHotspotX = -1;
 	_vm->_draw->_cursorHotspotY = -1;
 
+	_anims.clear();
+
+	_activeShots.clear();
+
+	for (uint i = 0; i < kMaxShotCount; i++) {
+		delete _shot[i];
+
+		_shot[i] = 0;
+	}
+
+	for (uint i = 0; i < kEvilFishCount; i++) {
+		delete _evilFish[i];
+
+		_evilFish[i] = 0;
+	}
+
 	delete _heart;
 	delete _lungs;
 	delete _water;
@@ -192,6 +214,17 @@ void Diving::initCursor() {
 	_vm->_draw->_cursorHotspotY = 8;
 }
 
+void Diving::evilFishEnter() {
+	for (uint i = 0; i < kEvilFishCount; i++) {
+		EvilFish &fish = *_evilFish[i];
+
+		if (fish.isVisible())
+			continue;
+
+		fish.enter((EvilFish::Direction)_vm->_util->getRandom(2), 90 + i * 20);
+	}
+}
+
 void Diving::foundBlackPearl() {
 	_blackPearlCount++;
 
@@ -215,6 +248,82 @@ void Diving::foundWhitePearl() {
 	_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, x, 177, x + 3, 180);
 }
 
+void Diving::updateAnims() {
+	int16 left, top, right, bottom;
+
+	// Clear the previous animation frames
+	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);
+	}
+
+	// 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);
+
+		(*a)->advance();
+	}
+}
+
+int16 Diving::checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons) {
+	_vm->_util->getMouseState(&mouseX, &mouseY, &mouseButtons);
+
+	return _vm->_util->checkKey();
+}
+
+void Diving::shoot(int16 mouseX, int16 mouseY) {
+	// Outside the playable area?
+	if (mouseY > 157)
+		return;
+
+	// Too many shots still active?
+	if (_activeShots.size() >= kMaxShotCount)
+		return;
+
+	ANIObject &shot = *_shot[_currentShot];
+
+	shot.rewind();
+	shot.setVisible(true);
+	shot.setPause(false);
+	shot.setPosition(mouseX - 8, mouseY - 8);
+
+	_activeShots.push_back(_currentShot);
+
+	_currentShot = (_currentShot + 1) % kMaxShotCount;
+}
+
+void Diving::checkShots() {
+	Common::List<int>::iterator activeShot = _activeShots.begin();
+
+	while (activeShot != _activeShots.end()) {
+		ANIObject &shot = *_shot[*activeShot];
+
+		if (shot.lastFrame()) {
+			int16 x, y;
+
+			shot.getPosition(x, y);
+
+			for (uint i = 0; i < kEvilFishCount; i++) {
+				EvilFish &evilFish = *_evilFish[i];
+
+				if (evilFish.isIn(x + 8, y + 8)) {
+					evilFish.die();
+
+					break;
+				}
+			}
+
+			activeShot = _activeShots.erase(activeShot);
+		} else
+			++activeShot;
+	}
+}
+
 } // End of namespace Geisha
 
 } // End of namespace Gob
diff --git a/engines/gob/minigames/geisha/diving.h b/engines/gob/minigames/geisha/diving.h
index 023ac91..dd0773a 100644
--- a/engines/gob/minigames/geisha/diving.h
+++ b/engines/gob/minigames/geisha/diving.h
@@ -33,8 +33,12 @@ class DECFile;
 class ANIFile;
 class ANIObject;
 
+enum MouseButtons;
+
 namespace Geisha {
 
+class EvilFish;
+
 /** Geisha's "Diving" minigame. */
 class Diving {
 public:
@@ -44,6 +48,9 @@ public:
 	bool play(uint16 playerCount, bool hasPearlLocation);
 
 private:
+	static const uint kEvilFishCount =  3;
+	static const uint kMaxShotCount  = 10;
+
 	GobEngine *_vm;
 
 	DECFile *_background;
@@ -55,19 +62,38 @@ private:
 	ANIObject *_lungs;
 	ANIObject *_heart;
 
+	EvilFish *_evilFish[kEvilFishCount];
+
+	ANIObject *_shot[kMaxShotCount];
+
+	Common::List<int> _activeShots;
+
+	Common::List<ANIObject *> _anims;
+
 	Surface *_blackPearl;
 
 	uint8 _whitePearlCount;
 	uint8 _blackPearlCount;
 
+	uint8 _currentShot;
+
 	void init();
 	void deinit();
 
 	void initScreen();
 	void initCursor();
 
+	void evilFishEnter();
+
 	void foundBlackPearl();
 	void foundWhitePearl();
+
+	void updateAnims();
+
+	int16 checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons);
+
+	void shoot(int16 mouseX, int16 mouseY);
+	void checkShots();
 };
 
 } // End of namespace Geisha
diff --git a/engines/gob/minigames/geisha/evilfish.h b/engines/gob/minigames/geisha/evilfish.h
index 9144cef..1801ad9 100644
--- a/engines/gob/minigames/geisha/evilfish.h
+++ b/engines/gob/minigames/geisha/evilfish.h
@@ -33,8 +33,8 @@ namespace Geisha {
 class EvilFish : public ANIObject {
 public:
 	enum Direction {
-		kDirectionLeft,
-		kDirectionRight
+		kDirectionLeft  = 0,
+		kDirectionRight = 1
 	};
 
 	EvilFish(const ANIFile &ani, uint16 screenWidth,






More information about the Scummvm-git-logs mailing list