aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorBastien Bouclet2010-11-29 20:53:56 +0000
committerBastien Bouclet2010-11-29 20:53:56 +0000
commit00e13f4c259baab292eb97b80fa50aa9a8385ca9 (patch)
treeedf1636941efe096c2cd97264fe1cd030990f27a /engines/mohawk
parent462a150b8ab87ea28fd364c48c8e14333be00a75 (diff)
downloadscummvm-rg350-00e13f4c259baab292eb97b80fa50aa9a8385ca9.tar.gz
scummvm-rg350-00e13f4c259baab292eb97b80fa50aa9a8385ca9.tar.bz2
scummvm-rg350-00e13f4c259baab292eb97b80fa50aa9a8385ca9.zip
MOHAWK : Implemented selenitic sound lock slider opcodes and adjusted sliders behaviour.
svn-id: r54610
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/myst_areas.cpp38
-rw-r--r--engines/mohawk/myst_areas.h6
-rw-r--r--engines/mohawk/myst_scripts_selenitic.cpp113
-rw-r--r--engines/mohawk/myst_scripts_selenitic.h4
-rw-r--r--engines/mohawk/sound.h3
5 files changed, 144 insertions, 20 deletions
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 009be0feff..5f61201225 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -467,8 +467,6 @@ MystResourceType10::MystResourceType10(MohawkEngine_Myst *vm, Common::SeekableRe
_background = 0;
_sliderWidth = _rect.right - _rect.left;
_sliderHeigth = _rect.bottom - _rect.top;
-
- warning("TODO: Card contains Type 10 Resource - Function not yet implemented");
}
MystResourceType10::~MystResourceType10() {
@@ -520,6 +518,10 @@ void MystResourceType10::drawDataToScreen() {
memcpy(_background->getBasePtr(0, i), screen->getBasePtr(bb.left, bb.top + i), bb.width() * _background->bytesPerPixel);
_vm->_system->unlockScreen();
+ } else {
+ // Restore background
+ Common::Rect bb = boundingBox();
+ _vm->_system->copyRectToScreen((byte *)_background->getBasePtr(0, 0), _background->pitch, bb.left, bb.top, bb.width(), bb.height());
}
@@ -532,7 +534,7 @@ void MystResourceType10::handleMouseDown(Common::Point *mouse) {
updatePosition(mouse);
- MystResourceType8::handleMouseDown(mouse);
+ MystResourceType11::handleMouseDown(mouse);
// Restore background
Common::Rect bb = boundingBox();
@@ -545,8 +547,6 @@ void MystResourceType10::handleMouseDown(Common::Point *mouse) {
void MystResourceType10::handleMouseUp(Common::Point *mouse) {
updatePosition(mouse);
- MystResourceType8::handleMouseUp(mouse);
-
// Restore background
Common::Rect bb = boundingBox();
_vm->_system->copyRectToScreen((byte *)_background->getBasePtr(0, 0), _background->pitch, bb.left, bb.top, bb.width(), bb.height());
@@ -571,6 +571,8 @@ void MystResourceType10::handleMouseUp(Common::Point *mouse) {
}
_vm->_scriptParser->setVarValue(_var8, value);
+ MystResourceType11::handleMouseUp(mouse);
+
// No longer in drag mode
_vm->_dragResource = 0;
}
@@ -578,7 +580,7 @@ void MystResourceType10::handleMouseUp(Common::Point *mouse) {
void MystResourceType10::handleMouseDrag(Common::Point *mouse) {
updatePosition(mouse);
- MystResourceType8::handleMouseDrag(mouse);
+ MystResourceType11::handleMouseDrag(mouse);
// Restore background
Common::Rect bb = boundingBox();
@@ -695,19 +697,19 @@ MystResourceType11::~MystResourceType11() {
void MystResourceType11::handleMouseDown(Common::Point *mouse) {
setPositionClipping(mouse, &_pos);
- _vm->_scriptParser->runOpcode(_mouseDownOpcode);
+ _vm->_scriptParser->runOpcode(_mouseDownOpcode, _var8);
}
void MystResourceType11::handleMouseUp(Common::Point *mouse) {
setPositionClipping(mouse, &_pos);
- _vm->_scriptParser->runOpcode(_mouseUpOpcode);
+ _vm->_scriptParser->runOpcode(_mouseUpOpcode, _var8);
}
void MystResourceType11::handleMouseDrag(Common::Point *mouse) {
setPositionClipping(mouse, &_pos);
- _vm->_scriptParser->runOpcode(_mouseDragOpcode);
+ _vm->_scriptParser->runOpcode(_mouseDragOpcode, _var8);
}
void MystResourceType11::setPositionClipping(Common::Point *mouse, Common::Point *dest) {
@@ -719,6 +721,24 @@ void MystResourceType11::setPositionClipping(Common::Point *mouse, Common::Point
}
}
+uint16 MystResourceType11::getList1(uint16 index) {
+ if (index < _lists[1].listCount) {
+ return _lists[1].list[index];
+ }
+}
+
+uint16 MystResourceType11::getList2(uint16 index) {
+ if (index < _lists[2].listCount) {
+ return _lists[2].list[index];
+ }
+}
+
+uint16 MystResourceType11::getList3(uint16 index) {
+ if (index < _lists[3].listCount) {
+ return _lists[3].list[index];
+ }
+}
+
MystResourceType12::MystResourceType12(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResourceType11(vm, rlstStream, parent) {
_numFrames = rlstStream->readUint16LE();
_firstFrame = rlstStream->readUint16LE();
diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index 9f4b9bca16..4a53577a3d 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -141,6 +141,11 @@ public:
void handleMouseUp(Common::Point *mouse);
void handleMouseDrag(Common::Point *mouse);
+ uint16 getList1(uint16 index);
+ uint16 getList2(uint16 index);
+ uint16 getList3(uint16 index);
+
+ Common::Point _pos;
protected:
void setPositionClipping(Common::Point *mouse, Common::Point *dest);
@@ -160,7 +165,6 @@ protected:
uint16 listCount;
uint16 *list;
} _lists[3];
- Common::Point _pos;
};
diff --git a/engines/mohawk/myst_scripts_selenitic.cpp b/engines/mohawk/myst_scripts_selenitic.cpp
index 18b3a7f31b..b7aa9ab868 100644
--- a/engines/mohawk/myst_scripts_selenitic.cpp
+++ b/engines/mohawk/myst_scripts_selenitic.cpp
@@ -278,16 +278,16 @@ bool MystScriptParser_Selenitic::setVarValue(uint16 var, uint16 value) {
case 20: // Sound lock sliders
selenitic_vars[13] = value;
break;
- case 21: // Sound lock sliders
+ case 21:
selenitic_vars[14] = value;
break;
- case 22: // Sound lock sliders
+ case 22:
selenitic_vars[15] = value;
break;
- case 23: // Sound lock sliders
+ case 23:
selenitic_vars[16] = value;
break;
- case 24: // Sound lock sliders
+ case 24:
selenitic_vars[17] = value;
break;
default:
@@ -528,19 +528,110 @@ void MystScriptParser_Selenitic::o_111_soundReceiverUpdateSound(uint16 op, uint1
sound_receiver_update_sound();
}
+uint16 MystScriptParser_Selenitic::soundLockCurrentSound(uint16 position, bool pixels) {
+ if ((pixels && position < 96) || (!pixels && position == 0)) {
+ return 289;
+ } else if ((pixels && position < 108) || (!pixels && position == 1)) {
+ return 1289;
+ } else if ((pixels && position < 120) || (!pixels && position == 2)) {
+ return 2289;
+ } else if ((pixels && position < 132) || (!pixels && position == 3)) {
+ return 3289;
+ } else if ((pixels && position < 144) || (!pixels && position == 4)) {
+ return 4289;
+ } else if ((pixels && position < 156) || (!pixels && position == 5)) {
+ return 5289;
+ } else if ((pixels && position < 168) || (!pixels && position == 6)) {
+ return 6289;
+ } else if ((pixels && position < 180) || (!pixels && position == 7)) {
+ return 7289;
+ } else if ((pixels && position < 192) || (!pixels && position == 8)) {
+ return 8289;
+ } else if (pixels || (!pixels && position == 8)) {
+ return 9289;
+ } else {
+ return 0;
+ }
+}
+
+MystResourceType10 *MystScriptParser_Selenitic::soundLockSliderFromVar(uint16 var) {
+ switch (var) {
+ case 20:
+ return _sound_lock_slider_1;
+ case 21:
+ return _sound_lock_slider_2;
+ case 22:
+ return _sound_lock_slider_3;
+ case 23:
+ return _sound_lock_slider_4;
+ case 24:
+ return _sound_lock_slider_5;
+ }
+
+ return 0;
+}
+
void MystScriptParser_Selenitic::o_112_soundLockMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- //varUnusedCheck(op, var);
- unknown(op, var, argc, argv);
+ MystResourceType10 *slider = soundLockSliderFromVar(var);
+
+ uint16 soundId = soundLockCurrentSound(slider->_pos.y, true);
+ if (_sound_lock_sound_id != soundId) {
+ _sound_lock_sound_id = soundId;
+ _vm->_sound->replaceSound(soundId, Audio::Mixer::kMaxChannelVolume, true);
+ }
}
void MystScriptParser_Selenitic::o_113_soundLockStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
- unknown(op, var, argc, argv);
+ MystResourceType10 *slider = soundLockSliderFromVar(var);
+
+ _vm->_gfx->changeCursor(700);
+ _vm->_sound->pauseBackground();
+
+ _sound_lock_sound_id = soundLockCurrentSound(slider->_pos.y, true);
+ _vm->_sound->replaceSound(_sound_lock_sound_id, Audio::Mixer::kMaxChannelVolume, true);
}
void MystScriptParser_Selenitic::o_114_soundLockEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
- unknown(op, var, argc, argv);
+ uint16 *selenitic_vars = _vm->_saveLoad->_v->selenitic_vars;
+ MystResourceType10 *slider = soundLockSliderFromVar(var);
+ uint16 *value = 0;
+
+ switch (var) {
+ case 20: // Sound lock sliders
+ value = &selenitic_vars[13];
+ break;
+ case 21:
+ value = &selenitic_vars[14];
+ break;
+ case 22:
+ value = &selenitic_vars[15];
+ break;
+ case 23:
+ value = &selenitic_vars[16];
+ break;
+ case 24:
+ value = &selenitic_vars[17];
+ break;
+ }
+
+ uint16 stepped = 12 * (*value / 12) + 6;
+
+ if ( stepped == 6 )
+ stepped = 0;
+ if ( stepped == 114 )
+ stepped = 119;
+
+ *value = stepped;
+
+ slider->setStep(stepped);
+ slider->drawDataToScreen();
+
+ uint16 soundId = slider->getList3(0);
+ if (soundId)
+ _vm->_sound->playSoundBlocking(soundId);
+
+ _vm->_sound->stopSound();
+ _vm->_sound->resumeBackground();
}
void MystScriptParser_Selenitic::o_115_soundLockButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@@ -865,6 +956,8 @@ void MystScriptParser_Selenitic::o_204_soundLock_init(uint16 op, uint16 var, uin
}
}
}
+
+ _sound_lock_sound_id = 0;
}
void MystScriptParser_Selenitic::opcode_205(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/myst_scripts_selenitic.h b/engines/mohawk/myst_scripts_selenitic.h
index f17b590376..fc07cfa3e9 100644
--- a/engines/mohawk/myst_scripts_selenitic.h
+++ b/engines/mohawk/myst_scripts_selenitic.h
@@ -93,6 +93,7 @@ private:
MystResource *_sound_receiver_angle_4; // 152
MystResource *_sound_receiver_sigma_button; // 156
+ uint16 _sound_lock_sound_id;
MystResourceType10 *_sound_lock_slider_1; // 164
MystResourceType10 *_sound_lock_slider_2; // 168
MystResourceType10 *_sound_lock_slider_3; // 172
@@ -109,6 +110,9 @@ private:
uint16 sound_receiver_current_sound(uint16 source, uint16 position);
void sound_receiver_solution(uint16 source, uint16 &solution, bool &enabled);
+ uint16 soundLockCurrentSound(uint16 position, bool pixels);
+ MystResourceType10 *soundLockSliderFromVar(uint16 var);
+
void draw_digit(MystResource *_resource);
};
diff --git a/engines/mohawk/sound.h b/engines/mohawk/sound.h
index 386eb78991..67a2165ae2 100644
--- a/engines/mohawk/sound.h
+++ b/engines/mohawk/sound.h
@@ -130,6 +130,9 @@ public:
void resumeSound();
bool isPlaying(uint16 id);
+ void pauseBackground() {}; //TODO: implement
+ void resumeBackground() {};
+
// Riven-specific
void playSLST(uint16 index, uint16 card);
void playSLST(SLSTRecord slstRecord);