aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb
diff options
context:
space:
mode:
authorBertrand Augereau2012-03-03 14:18:05 +0100
committerBertrand Augereau2012-03-03 14:18:05 +0100
commit1098e6b79afb9208b3558bc0401afa0027179fbb (patch)
treec9114a97ad62a306ab0fdad394a90304b801b037 /engines/dreamweb
parent83f193edbd97af01904c45934bfaafb4c11efecc (diff)
downloadscummvm-rg350-1098e6b79afb9208b3558bc0401afa0027179fbb.tar.gz
scummvm-rg350-1098e6b79afb9208b3558bc0401afa0027179fbb.tar.bz2
scummvm-rg350-1098e6b79afb9208b3558bc0401afa0027179fbb.zip
DREAMWEB: The rain processing has its own cpp file
Diffstat (limited to 'engines/dreamweb')
-rw-r--r--engines/dreamweb/module.mk1
-rw-r--r--engines/dreamweb/rain.cpp202
-rw-r--r--engines/dreamweb/sprite.cpp175
3 files changed, 204 insertions, 174 deletions
diff --git a/engines/dreamweb/module.mk b/engines/dreamweb/module.mk
index 661a9b973a..6bc4f8728e 100644
--- a/engines/dreamweb/module.mk
+++ b/engines/dreamweb/module.mk
@@ -12,6 +12,7 @@ MODULE_OBJS := \
pathfind.o \
people.o \
print.o \
+ rain.o \
saveload.o \
sound.o \
sprite.o \
diff --git a/engines/dreamweb/rain.cpp b/engines/dreamweb/rain.cpp
new file mode 100644
index 0000000000..0a8ee2a38e
--- /dev/null
+++ b/engines/dreamweb/rain.cpp
@@ -0,0 +1,202 @@
+/* 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 "dreamweb/dreamweb.h"
+
+namespace DreamWeb {
+
+void DreamWebEngine::showRain() {
+ Common::List<Rain>::iterator i;
+
+ // Do nothing if there's no rain at all
+ if (_rainList.empty())
+ return;
+
+ const uint8 *frameData = _mainSprites.getFrameData(58);
+
+ for (i = _rainList.begin(); i != _rainList.end(); ++i) {
+ Rain &rain = *i;
+ uint16 y = rain.y + _mapAdY + _mapYStart;
+ uint16 x = rain.x + _mapAdX + _mapXStart;
+ uint16 size = rain.size;
+ uint16 offset = (rain.w3 - rain.b5) & 511;
+ rain.w3 = offset;
+ const uint8 *src = frameData + offset;
+ uint8 *dst = workspace() + y * 320 + x;
+ for (uint16 j = 0; j < size; ++j) {
+ uint8 v = src[j];
+ if (v != 0)
+ *dst = v;
+ dst += 320-1; // advance diagonally
+ }
+ }
+
+ if (_channel1Playing != 255)
+ return;
+ if (_realLocation == 2 && _vars._beenMugged != 1)
+ return;
+ if (_realLocation == 55)
+ return;
+
+ if (randomNumber() >= 1) // play thunder with 1 in 256 chance
+ return;
+
+ uint8 soundIndex;
+ if (_channel0Playing != 6)
+ soundIndex = 4;
+ else
+ soundIndex = 7;
+ playChannel1(soundIndex);
+}
+
+uint8 DreamWebEngine::getBlockOfPixel(uint8 x, uint8 y) {
+ uint8 flag, flagEx, type, flagX, flagY;
+ checkOne(x + _mapXStart, y + _mapYStart, &flag, &flagEx, &type, &flagX, &flagY);
+ if (flag & 1)
+ return 0;
+ else
+ return type;
+}
+
+void DreamWebEngine::splitIntoLines(uint8 x, uint8 y) {
+ do {
+ Rain rain;
+
+ // Look for line start
+ while (!getBlockOfPixel(x, y)) {
+ --x;
+ ++y;
+ if (x == 0 || y >= _mapYSize)
+ return;
+ }
+
+ rain.x = x;
+ rain.y = y;
+
+ uint8 length = 1;
+
+ // Look for line end
+ while (getBlockOfPixel(x, y)) {
+ --x;
+ ++y;
+ if (x == 0 || y >= _mapYSize)
+ break;
+ ++length;
+ }
+
+ rain.size = length;
+ rain.w3 = (randomNumber() << 8) | randomNumber();
+ rain.b5 = (randomNumber() & 3) + 4;
+ _rainList.push_back(rain);
+ } while (x > 0 && y < _mapYSize);
+}
+
+struct RainLocation {
+ uint8 location;
+ uint8 x, y;
+ uint8 rainSpacing;
+};
+
+static const RainLocation rainLocationList[] = {
+ { 1,44,10,16 },
+ { 4,11,30,14 },
+ { 4,22,30,14 },
+ { 3,33,10,14 },
+ { 10,33,30,14 },
+ { 10,22,30,24 },
+ { 9,22,10,14 },
+ { 2,33,0,14 },
+ { 2,22,0,14 },
+ { 6,11,30,14 },
+ { 7,11,20,18 },
+ { 7,0,20,18 },
+ { 7,0,30,18 },
+ { 55,44,0,14 },
+ { 5,22,30,14 },
+
+ { 8,0,10,18 },
+ { 8,11,10,18 },
+ { 8,22,10,18 },
+ { 8,33,10,18 },
+ { 8,33,20,18 },
+ { 8,33,30,18 },
+ { 8,33,40,18 },
+ { 8,22,40,18 },
+ { 8,11,40,18 },
+
+ { 21,44,20,18 },
+ { 255,0,0,0 }
+};
+
+void DreamWebEngine::initRain() {
+ const RainLocation *r = rainLocationList;
+ _rainList.clear();
+
+ uint8 rainSpacing = 0;
+
+ // look up location in rainLocationList to determine rainSpacing
+ for (r = rainLocationList; r->location != 0xff; ++r) {
+ if (r->location == _realLocation &&
+ r->x == _mapX && r->y == _mapY) {
+ rainSpacing = r->rainSpacing;
+ break;
+ }
+ }
+
+ if (rainSpacing == 0) {
+ // location not found in rainLocationList: no rain
+ return;
+ }
+
+ // start lines of rain from top of screen
+ uint8 x = 4;
+ do {
+ uint8 delta;
+ do {
+ delta = (randomNumber() & 31) + 3;
+ } while (delta >= rainSpacing);
+
+ x += delta;
+ if (x >= _mapXSize)
+ break;
+
+ splitIntoLines(x, 0);
+ } while (true);
+
+ // start lines of rain from side of screen
+ uint8 y = 0;
+ do {
+ uint8 delta;
+ do {
+ delta = (randomNumber() & 31) + 3;
+ } while (delta >= rainSpacing);
+
+ y += delta;
+ if (y >= _mapYSize)
+ break;
+
+ splitIntoLines(_mapXSize - 1, y);
+ } while (true);
+}
+
+} // End of namespace DreamWeb
+
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index b1aae5adce..4bbc31b54e 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -471,50 +471,6 @@ const Frame *DreamWebEngine::getReelFrameAX(uint16 frame) {
return &base->_frames[frame];
}
-void DreamWebEngine::showRain() {
- Common::List<Rain>::iterator i;
-
- // Do nothing if there's no rain at all
- if (_rainList.empty())
- return;
-
- const uint8 *frameData = _mainSprites.getFrameData(58);
-
- for (i = _rainList.begin(); i != _rainList.end(); ++i) {
- Rain &rain = *i;
- uint16 y = rain.y + _mapAdY + _mapYStart;
- uint16 x = rain.x + _mapAdX + _mapXStart;
- uint16 size = rain.size;
- uint16 offset = (rain.w3 - rain.b5) & 511;
- rain.w3 = offset;
- const uint8 *src = frameData + offset;
- uint8 *dst = workspace() + y * 320 + x;
- for (uint16 j = 0; j < size; ++j) {
- uint8 v = src[j];
- if (v != 0)
- *dst = v;
- dst += 320-1; // advance diagonally
- }
- }
-
- if (_channel1Playing != 255)
- return;
- if (_realLocation == 2 && _vars._beenMugged != 1)
- return;
- if (_realLocation == 55)
- return;
-
- if (randomNumber() >= 1) // play thunder with 1 in 256 chance
- return;
-
- uint8 soundIndex;
- if (_channel0Playing != 6)
- soundIndex = 4;
- else
- soundIndex = 7;
- playChannel1(soundIndex);
-}
-
void DreamWebEngine::moveMap(uint8 param) {
switch (param) {
case 32:
@@ -545,136 +501,6 @@ void DreamWebEngine::checkOne(uint8 x, uint8 y, uint8 *flag, uint8 *flagEx, uint
*type = tileData._type;
}
-uint8 DreamWebEngine::getBlockOfPixel(uint8 x, uint8 y) {
- uint8 flag, flagEx, type, flagX, flagY;
- checkOne(x + _mapXStart, y + _mapYStart, &flag, &flagEx, &type, &flagX, &flagY);
- if (flag & 1)
- return 0;
- else
- return type;
-}
-
-void DreamWebEngine::splitIntoLines(uint8 x, uint8 y) {
- do {
- Rain rain;
-
- // Look for line start
- while (!getBlockOfPixel(x, y)) {
- --x;
- ++y;
- if (x == 0 || y >= _mapYSize)
- return;
- }
-
- rain.x = x;
- rain.y = y;
-
- uint8 length = 1;
-
- // Look for line end
- while (getBlockOfPixel(x, y)) {
- --x;
- ++y;
- if (x == 0 || y >= _mapYSize)
- break;
- ++length;
- }
-
- rain.size = length;
- rain.w3 = (randomNumber() << 8) | randomNumber();
- rain.b5 = (randomNumber() & 3) + 4;
- _rainList.push_back(rain);
- } while (x > 0 && y < _mapYSize);
-}
-
-struct RainLocation {
- uint8 location;
- uint8 x, y;
- uint8 rainSpacing;
-};
-
-static const RainLocation rainLocationList[] = {
- { 1,44,10,16 },
- { 4,11,30,14 },
- { 4,22,30,14 },
- { 3,33,10,14 },
- { 10,33,30,14 },
- { 10,22,30,24 },
- { 9,22,10,14 },
- { 2,33,0,14 },
- { 2,22,0,14 },
- { 6,11,30,14 },
- { 7,11,20,18 },
- { 7,0,20,18 },
- { 7,0,30,18 },
- { 55,44,0,14 },
- { 5,22,30,14 },
-
- { 8,0,10,18 },
- { 8,11,10,18 },
- { 8,22,10,18 },
- { 8,33,10,18 },
- { 8,33,20,18 },
- { 8,33,30,18 },
- { 8,33,40,18 },
- { 8,22,40,18 },
- { 8,11,40,18 },
-
- { 21,44,20,18 },
- { 255,0,0,0 }
-};
-
-void DreamWebEngine::initRain() {
- const RainLocation *r = rainLocationList;
- _rainList.clear();
-
- uint8 rainSpacing = 0;
-
- // look up location in rainLocationList to determine rainSpacing
- for (r = rainLocationList; r->location != 0xff; ++r) {
- if (r->location == _realLocation &&
- r->x == _mapX && r->y == _mapY) {
- rainSpacing = r->rainSpacing;
- break;
- }
- }
-
- if (rainSpacing == 0) {
- // location not found in rainLocationList: no rain
- return;
- }
-
- // start lines of rain from top of screen
- uint8 x = 4;
- do {
- uint8 delta;
- do {
- delta = (randomNumber() & 31) + 3;
- } while (delta >= rainSpacing);
-
- x += delta;
- if (x >= _mapXSize)
- break;
-
- splitIntoLines(x, 0);
- } while (true);
-
- // start lines of rain from side of screen
- uint8 y = 0;
- do {
- uint8 delta;
- do {
- delta = (randomNumber() & 31) + 3;
- } while (delta >= rainSpacing);
-
- y += delta;
- if (y >= _mapYSize)
- break;
-
- splitIntoLines(_mapXSize - 1, y);
- } while (true);
-}
-
void DreamWebEngine::intro1Text() {
if (_introCount != 2 && _introCount != 4 && _introCount != 6)
return;
@@ -1192,3 +1018,4 @@ void DreamWebEngine::checkForExit(Sprite *sprite) {
}
} // End of namespace DreamWeb
+