aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBenjamin Haisch2009-05-13 12:17:53 +0000
committerWillem Jan Palenstijn2011-11-20 22:43:07 +0100
commit041fe21417d107dd558212ba70004d71d02e0355 (patch)
treec9dffc10744299590a1c5f78ec9eb29fa5f0886c /engines
parent170b66b2cbf9c43d3bfe5e1c1a22723dba51f565 (diff)
downloadscummvm-rg350-041fe21417d107dd558212ba70004d71d02e0355.tar.gz
scummvm-rg350-041fe21417d107dd558212ba70004d71d02e0355.tar.bz2
scummvm-rg350-041fe21417d107dd558212ba70004d71d02e0355.zip
TOLTECS: - Added enum for sound channel type
- Added isPointInside
Diffstat (limited to 'engines')
-rw-r--r--engines/toltecs/segmap.cpp13
-rw-r--r--engines/toltecs/segmap.h3
-rw-r--r--engines/toltecs/sound.cpp30
-rw-r--r--engines/toltecs/sound.h25
4 files changed, 38 insertions, 33 deletions
diff --git a/engines/toltecs/segmap.cpp b/engines/toltecs/segmap.cpp
index 4647f79388..b51886f19f 100644
--- a/engines/toltecs/segmap.cpp
+++ b/engines/toltecs/segmap.cpp
@@ -341,7 +341,7 @@ void SegmentMap::findPath(int16 *pointsArray, int16 destX, int16 destY, int16 so
debug(0, "SegmentMap::findPath() count = %d", pointsArray[1]);
-#if 0 // DEBUG: Draw the path we found
+#if 1 // DEBUG: Draw the path we found
int sx = sourceX, sy = sourceY;
LineData ld;
ld.pitch = _vm->_sceneWidth;
@@ -359,10 +359,7 @@ void SegmentMap::findPath(int16 *pointsArray, int16 destX, int16 destY, int16 so
int8 SegmentMap::getScalingAtPoint(int16 x, int16 y) {
int8 scaling = 0;
for (uint i = 0; i < _infoRects.size(); i++) {
- if (_infoRects[i].id == 0 &&
- y >= _infoRects[i].y && y <= _infoRects[i].y + _infoRects[i].height &&
- x >= _infoRects[i].x && x <= _infoRects[i].x + _infoRects[i].width) {
-
+ if (_infoRects[i].id == 0 && _infoRects[i].isPointInside(x, y)) {
int8 topScaling = (int8)_infoRects[i].b;
int8 bottomScaling = (int8)_infoRects[i].c;
if (y - _infoRects[i].y > 0) {
@@ -370,6 +367,7 @@ int8 SegmentMap::getScalingAtPoint(int16 x, int16 y) {
}
}
}
+ debug(0, "SegmentMap::getScalingAtPoint(%d, %d) %d", x, y, scaling);
return scaling;
}
@@ -378,10 +376,7 @@ void SegmentMap::getRgbModifiertAtPoint(int16 x, int16 y, int16 id, byte &r, byt
g = 0;
b = 0;
for (uint i = 0; i < _infoRects.size(); i++) {
- if (_infoRects[i].id == id &&
- y >= _infoRects[i].y && y <= _infoRects[i].y + _infoRects[i].height &&
- x >= _infoRects[i].x && x <= _infoRects[i].x + _infoRects[i].width) {
-
+ if (_infoRects[i].id == id && _infoRects[i].isPointInside(x, y)) {
r = _infoRects[i].a;
g = _infoRects[i].b;
b = _infoRects[i].c;
diff --git a/engines/toltecs/segmap.h b/engines/toltecs/segmap.h
index 77ab247c72..b860efb2ce 100644
--- a/engines/toltecs/segmap.h
+++ b/engines/toltecs/segmap.h
@@ -92,6 +92,9 @@ public: // for debugging purposes
int16 height, width;
byte id;
byte a, b, c;
+ inline bool isPointInside(int16 px, int16 py) {
+ return py >= y && py <= y + height && px >= x && px <= x + width;
+ }
};
struct PathPoint {
diff --git a/engines/toltecs/sound.cpp b/engines/toltecs/sound.cpp
index cb7b2343bb..3f1be4be89 100644
--- a/engines/toltecs/sound.cpp
+++ b/engines/toltecs/sound.cpp
@@ -47,7 +47,7 @@ namespace Toltecs {
Sound::Sound(ToltecsEngine *vm) : _vm(vm) {
for (int i = 0; i < 4; i++) {
- channels[i].type = 0;
+ channels[i].type = kChannelTypeEmpty;
channels[i].resIndex = -1;
}
}
@@ -61,7 +61,7 @@ void Sound::playSpeech(int16 resIndex) {
debug(0, "playSpeech(%d)", resIndex);
- internalPlaySound(resIndex, -3, 50 /*TODO*/, 64);
+ internalPlaySound(resIndex, kChannelTypeSpeech, 50 /*TODO*/, 64);
}
@@ -71,8 +71,8 @@ void Sound::playSound(int16 resIndex, int16 type, int16 volume) {
debug(0, "playSound(%d, %d, %d)", resIndex, type, volume);
- if (volume == -1 || type == -2) {
- if (type == -1) {
+ if (volume == -1 || type == kChannelTypeSfx) {
+ if (type == kChannelTypeBackground) {
internalPlaySound(resIndex, type, 50 /*TODO*/, 64);
} else {
internalPlaySound(resIndex, type, 100 /*TODO*/, 64);
@@ -102,29 +102,29 @@ void Sound::internalPlaySound(int16 resIndex, int16 type, int16 volume, int16 pa
_vm->_mixer->stopAll();
_vm->_screen->keepTalkTextItemsAlive();
for (int i = 0; i < 4; i++) {
- channels[i].type = 0;
+ channels[i].type = kChannelTypeEmpty;
channels[i].resIndex = -1;
}
- } else if (type == -2) {
+ } else if (type == kChannelTypeSfx) {
// Stop sounds with specified resIndex
for (int i = 0; i < 4; i++) {
if (channels[i].resIndex == resIndex) {
_vm->_mixer->stopHandle(channels[i].handle);
- channels[i].type = 0;
+ channels[i].type = kChannelTypeEmpty;
channels[i].resIndex = -1;
}
}
} else {
- if (type == -3) {
- // Stop sounds with type == -3 and play new sound
+ if (type == kChannelTypeSpeech) {
+ // Stop speech and play new sound
stopSpeech();
}
// Play new sound in empty channel
int freeChannel = -1;
for (int i = 0; i < 4; i++) {
- if (channels[i].type == 0) {
+ if (channels[i].type == kChannelTypeEmpty) {
freeChannel = i;
break;
}
@@ -137,8 +137,8 @@ void Sound::internalPlaySound(int16 resIndex, int16 type, int16 volume, int16 pa
uint32 soundSize = _vm->_res->getCurItemSize();
byte flags = Audio::Mixer::FLAG_UNSIGNED;
- // Sounds with type == -1 loop
- if (type == -1)
+ // Background sounds
+ if (type == kChannelTypeBackground)
flags |= Audio::Mixer::FLAG_LOOP;
Audio::AudioStream *stream = Audio::makeLinearInputStream(soundData, soundSize, 22050, flags, 0, 0);
@@ -156,7 +156,7 @@ void Sound::internalPlaySound(int16 resIndex, int16 type, int16 volume, int16 pa
void Sound::updateSpeech() {
for (int i = 0; i < 4; i++) {
- if (channels[i].type == -3 && _vm->_mixer->isSoundHandleActive(channels[i].handle)) {
+ if (channels[i].type == kChannelTypeSpeech && _vm->_mixer->isSoundHandleActive(channels[i].handle)) {
_vm->_screen->keepTalkTextItemsAlive();
break;
}
@@ -165,10 +165,10 @@ void Sound::updateSpeech() {
void Sound::stopSpeech() {
for (int i = 0; i < 4; i++) {
- if (channels[i].type == -3) {
+ if (channels[i].type == kChannelTypeSpeech) {
_vm->_mixer->stopHandle(channels[i].handle);
_vm->_screen->keepTalkTextItemsAlive();
- channels[i].type = 0;
+ channels[i].type = kChannelTypeEmpty;
channels[i].resIndex = -1;
}
}
diff --git a/engines/toltecs/sound.h b/engines/toltecs/sound.h
index 02f7a96eb3..7552d85ae8 100644
--- a/engines/toltecs/sound.h
+++ b/engines/toltecs/sound.h
@@ -48,6 +48,13 @@ namespace Toltecs {
// 0x1219
+enum SoundChannelType {
+ kChannelTypeEmpty = 0,
+ kChannelTypeBackground = -1,
+ kChannelTypeSfx = -2,
+ kChannelTypeSpeech = -3
+};
+
struct SoundChannel {
int16 resIndex;
int16 type;
@@ -56,22 +63,22 @@ struct SoundChannel {
class Sound {
public:
- Sound(ToltecsEngine *vm);
- ~Sound();
+ Sound(ToltecsEngine *vm);
+ ~Sound();
- void playSpeech(int16 resIndex);
- void playSound(int16 resIndex, int16 type, int16 volume);
+ void playSpeech(int16 resIndex);
+ void playSound(int16 resIndex, int16 type, int16 volume);
void playSoundAtPos(int16 resIndex, int16 x, int16 y);
void updateSpeech();
void stopSpeech();
protected:
- ToltecsEngine *_vm;
+ ToltecsEngine *_vm;
+
+ SoundChannel channels[4];
+
+ void internalPlaySound(int16 resIndex, int16 type, int16 volume, int16 panning);
- SoundChannel channels[4];
-
- void internalPlaySound(int16 resIndex, int16 type, int16 volume, int16 panning);
-
};