aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2010-11-22 17:50:30 +0000
committerMatthew Hoops2010-11-22 17:50:30 +0000
commitcc6c7e33bff84f12512d01058c3f5a384ff36c83 (patch)
tree942c01d5de9829cd7dd00a8d542f38120e9a2475
parenteba5c441b27d0c7ec82b4d7abd0f51bfee2dc8ba (diff)
downloadscummvm-rg350-cc6c7e33bff84f12512d01058c3f5a384ff36c83.tar.gz
scummvm-rg350-cc6c7e33bff84f12512d01058c3f5a384ff36c83.tar.bz2
scummvm-rg350-cc6c7e33bff84f12512d01058c3f5a384ff36c83.zip
MOHAWK: Switch slider bitmap ID's to matching via string; fixes some versions
svn-id: r54416
-rw-r--r--engines/mohawk/mohawk.cpp18
-rw-r--r--engines/mohawk/mohawk.h2
-rw-r--r--engines/mohawk/resource.cpp47
-rw-r--r--engines/mohawk/resource.h3
-rw-r--r--engines/mohawk/riven_external.cpp35
-rw-r--r--engines/mohawk/riven_external.h6
6 files changed, 49 insertions, 62 deletions
diff --git a/engines/mohawk/mohawk.cpp b/engines/mohawk/mohawk.cpp
index 54e753dfe5..4558f95d0b 100644
--- a/engines/mohawk/mohawk.cpp
+++ b/engines/mohawk/mohawk.cpp
@@ -93,15 +93,6 @@ Common::SeekableReadStream *MohawkEngine::getResource(uint32 tag, uint16 id) {
return NULL;
}
-Common::SeekableReadStream *MohawkEngine::getResource(uint32 tag, const Common::String &resName) {
- for (uint32 i = 0; i < _mhk.size(); i++)
- if (_mhk[i]->hasResource(tag, resName))
- return _mhk[i]->getResource(tag, resName);
-
- error("Could not find a '%s' resource matching name '%s'", tag2str(tag), resName.c_str());
- return NULL;
-}
-
bool MohawkEngine::hasResource(uint32 tag, uint16 id) {
for (uint32 i = 0; i < _mhk.size(); i++)
if (_mhk[i]->hasResource(tag, id))
@@ -127,4 +118,13 @@ uint32 MohawkEngine::getResourceOffset(uint32 tag, uint16 id) {
return 0;
}
+uint16 MohawkEngine::findResourceID(uint32 tag, const Common::String &resName) {
+ for (uint32 i = 0; i < _mhk.size(); i++)
+ if (_mhk[i]->hasResource(tag, resName))
+ return _mhk[i]->findResourceID(tag, resName);
+
+ error("Could not find a '%s' resource matching name '%s'", tag2str(tag), resName.c_str());
+ return 0xFFFF;
+}
+
} // End of namespace Mohawk
diff --git a/engines/mohawk/mohawk.h b/engines/mohawk/mohawk.h
index d53c080f40..3fe63c962a 100644
--- a/engines/mohawk/mohawk.h
+++ b/engines/mohawk/mohawk.h
@@ -100,10 +100,10 @@ public:
VideoManager *_video;
virtual Common::SeekableReadStream *getResource(uint32 tag, uint16 id);
- Common::SeekableReadStream *getResource(uint32 tag, const Common::String &resName);
bool hasResource(uint32 tag, uint16 id);
bool hasResource(uint32 tag, const Common::String &resName);
uint32 getResourceOffset(uint32 tag, uint16 id);
+ uint16 findResourceID(uint32 type, const Common::String &resName);
void pauseGame();
diff --git a/engines/mohawk/resource.cpp b/engines/mohawk/resource.cpp
index 1ae069e459..e9e1c6b792 100644
--- a/engines/mohawk/resource.cpp
+++ b/engines/mohawk/resource.cpp
@@ -192,7 +192,7 @@ int MohawkArchive::getIDIndex(int typeIndex, const Common::String &resName) {
for (uint16 i = 0; i < _types[typeIndex].nameTable.num; i++)
if (_types[typeIndex].nameTable.entries[i].name.matchString(resName)) {
- index = i;
+ index = _types[typeIndex].nameTable.entries[i].index;
break;
}
@@ -206,6 +206,20 @@ int MohawkArchive::getIDIndex(int typeIndex, const Common::String &resName) {
return -1; // Not found
}
+uint16 MohawkArchive::findResourceID(uint32 type, const Common::String &resName) {
+ int typeIndex = getTypeIndex(type);
+
+ if (typeIndex < 0)
+ return 0xFFFF;
+
+ int idIndex = getIDIndex(typeIndex, resName);
+
+ if (idIndex < 0)
+ return 0xFFFF;
+
+ return _types[typeIndex].resTable.entries[idIndex].id;
+}
+
bool MohawkArchive::hasResource(uint32 tag, uint16 id) {
if (!_mhk)
return false;
@@ -273,37 +287,6 @@ Common::SeekableReadStream *MohawkArchive::getResource(uint32 tag, uint16 id) {
return new Common::SeekableSubReadStream(_mhk, _fileTable[fileTableIndex].offset, _fileTable[fileTableIndex].offset + _fileTable[fileTableIndex].dataSize);
}
-Common::SeekableReadStream *MohawkArchive::getResource(uint32 tag, const Common::String &resName) {
- if (!_mhk)
- error("MohawkArchive::getResource(): No File in Use");
-
- int16 typeIndex = getTypeIndex(tag);
-
- if (typeIndex < 0)
- error("Could not find a tag of '%s' in file '%s'", tag2str(tag), _curFile.c_str());
-
- int16 idIndex = getIDIndex(typeIndex, resName);
-
- if (idIndex < 0)
- error("Could not find '%s' '%s' in file '%s'", tag2str(tag), resName.c_str(), _curFile.c_str());
-
- // Note: the fileTableIndex is based off 1, not 0. So, subtract 1
- uint16 fileTableIndex = _types[typeIndex].resTable.entries[idIndex].index - 1;
-
- // WORKAROUND: tMOV resources pretty much ignore the size part of the file table,
- // as the original just passed the full Mohawk file to QuickTime and the offset.
- // We need to do this because of the way Mohawk is set up (this is much more "proper"
- // than passing _mhk at the right offset). We may want to do that in the future, though.
- if (_types[typeIndex].tag == ID_TMOV) {
- if (fileTableIndex == _fileTableAmount)
- return new Common::SeekableSubReadStream(_mhk, _fileTable[fileTableIndex].offset, _mhk->size());
- else
- return new Common::SeekableSubReadStream(_mhk, _fileTable[fileTableIndex].offset, _fileTable[fileTableIndex + 1].offset);
- }
-
- return new Common::SeekableSubReadStream(_mhk, _fileTable[fileTableIndex].offset, _fileTable[fileTableIndex].offset + _fileTable[fileTableIndex].dataSize);
-}
-
void LivingBooksArchive_v1::open(Common::SeekableReadStream *stream) {
close();
_mhk = stream;
diff --git a/engines/mohawk/resource.h b/engines/mohawk/resource.h
index e710cb1b10..00cd46ba1c 100644
--- a/engines/mohawk/resource.h
+++ b/engines/mohawk/resource.h
@@ -186,8 +186,8 @@ public:
virtual bool hasResource(uint32 tag, uint16 id);
virtual bool hasResource(uint32 tag, const Common::String &resName);
virtual Common::SeekableReadStream *getResource(uint32 tag, uint16 id);
- virtual Common::SeekableReadStream *getResource(uint32 tag, const Common::String &resName);
virtual uint32 getOffset(uint32 tag, uint16 id);
+ virtual uint16 findResourceID(uint32 type, const Common::String &resName);
protected:
Common::SeekableReadStream *_mhk;
@@ -220,6 +220,7 @@ public:
Common::SeekableReadStream *getResource(uint32 tag, uint16 id);
Common::SeekableReadStream *getResource(uint32 tag, const Common::String &resName) { return 0; }
uint32 getOffset(uint32 tag, uint16 id);
+ uint16 findResourceID(uint32 type, const Common::String &resName) { return 0xFFFF; }
private:
struct OldType {
diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp
index 704301c454..e3b9ea3a69 100644
--- a/engines/mohawk/riven_external.cpp
+++ b/engines/mohawk/riven_external.cpp
@@ -259,7 +259,7 @@ void RivenExternal::runDomeCheck() {
*_vm->getVar("domecheck") = 1;
}
-void RivenExternal::resetDomeSliders(uint16 bitmapId, uint16 soundId, uint16 startHotspot) {
+void RivenExternal::resetDomeSliders(uint16 soundId, uint16 startHotspot) {
// The rightmost slider should move left until it finds the next slider,
// then those two continue until they find the third slider. This continues
// until all five sliders have returned their starting slots.
@@ -280,7 +280,7 @@ void RivenExternal::resetDomeSliders(uint16 bitmapId, uint16 soundId, uint16 sta
// so we should redraw and play a tick sound
if (slidersFound) {
_vm->_sound->playSound(soundId);
- drawDomeSliders(bitmapId, startHotspot);
+ drawDomeSliders(startHotspot);
_vm->_system->delayMillis(100);
}
}
@@ -318,7 +318,7 @@ void RivenExternal::checkSliderCursorChange(uint16 startHotspot) {
}
}
-void RivenExternal::dragDomeSlider(uint16 bitmapId, uint16 soundId, uint16 resetSlidersHotspot, uint16 openDomeHotspot, uint16 startHotspot) {
+void RivenExternal::dragDomeSlider(uint16 soundId, uint16 resetSlidersHotspot, uint16 openDomeHotspot, uint16 startHotspot) {
int16 foundSlider = -1;
for (uint16 i = 0; i < kDomeSliderSlotCount; i++) {
@@ -353,7 +353,7 @@ void RivenExternal::dragDomeSlider(uint16 bitmapId, uint16 soundId, uint16 reset
// Now play a click sound and redraw
_vm->_sound->playSound(soundId);
- drawDomeSliders(bitmapId, startHotspot);
+ drawDomeSliders(startHotspot);
} else if (foundSlider > 0 && !(_sliderState & (1 << (25 - foundSlider))) && _vm->_hotspots[foundSlider + startHotspot - 1].rect.contains(event.mouse)) {
// We've moved the slider left one space
_sliderState &= ~(_sliderState & (1 << (24 - foundSlider)));
@@ -362,7 +362,7 @@ void RivenExternal::dragDomeSlider(uint16 bitmapId, uint16 soundId, uint16 reset
// Now play a click sound and redraw
_vm->_sound->playSound(soundId);
- drawDomeSliders(bitmapId, startHotspot);
+ drawDomeSliders(startHotspot);
} else
_vm->_system->updateScreen(); // A normal update for the cursor
break;
@@ -380,7 +380,7 @@ void RivenExternal::dragDomeSlider(uint16 bitmapId, uint16 soundId, uint16 reset
checkDomeSliders(resetSlidersHotspot, openDomeHotspot);
}
-void RivenExternal::drawDomeSliders(uint16 bitmapId, uint16 startHotspot) {
+void RivenExternal::drawDomeSliders(uint16 startHotspot) {
Common::Rect dstAreaRect = Common::Rect(200, 250, 420, 319);
// On pspit, the rect is different by two pixels
@@ -388,6 +388,9 @@ void RivenExternal::drawDomeSliders(uint16 bitmapId, uint16 startHotspot) {
if (_vm->getCurStack() == pspit)
dstAreaRect.translate(-2, 0);
+ // Find out bitmap id
+ uint16 bitmapId = _vm->findResourceID(ID_TBMP, "*sliders*");
+
for (uint16 i = 0; i < kDomeSliderSlotCount; i++) {
Common::Rect srcRect = _vm->_hotspots[startHotspot + i].rect;
srcRect.translate(-dstAreaRect.left, -dstAreaRect.top); // Adjust the rect so it's in the destination area
@@ -934,11 +937,11 @@ void RivenExternal::xbisland190_opencard(uint16 argc, uint16 *argv) {
}
void RivenExternal::xbisland190_resetsliders(uint16 argc, uint16 *argv) {
- resetDomeSliders(701, 41, 2);
+ resetDomeSliders(41, 2);
}
void RivenExternal::xbisland190_slidermd(uint16 argc, uint16 *argv) {
- dragDomeSlider(701, 41, 27, 28, 2);
+ dragDomeSlider(41, 27, 28, 2);
}
void RivenExternal::xbisland190_slidermw(uint16 argc, uint16 *argv) {
@@ -1057,11 +1060,11 @@ void RivenExternal::xgisland25_opencard(uint16 argc, uint16 *argv) {
}
void RivenExternal::xgisland25_resetsliders(uint16 argc, uint16 *argv) {
- resetDomeSliders(161, 16, 2);
+ resetDomeSliders(16, 2);
}
void RivenExternal::xgisland25_slidermd(uint16 argc, uint16 *argv) {
- dragDomeSlider(161, 16, 29, 30, 2);
+ dragDomeSlider(16, 29, 30, 2);
}
void RivenExternal::xgisland25_slidermw(uint16 argc, uint16 *argv) {
@@ -1341,11 +1344,11 @@ void RivenExternal::xvga1300_carriage(uint16 argc, uint16 *argv) {
}
void RivenExternal::xjdome25_resetsliders(uint16 argc, uint16 *argv) {
- resetDomeSliders(_vm->getFeatures() & GF_DVD ? 547 : 548, 81, 2);
+ resetDomeSliders(81, 2);
}
void RivenExternal::xjdome25_slidermd(uint16 argc, uint16 *argv) {
- dragDomeSlider(_vm->getFeatures() & GF_DVD ? 547: 548, 81, 29, 28, 2);
+ dragDomeSlider(81, 29, 28, 2);
}
void RivenExternal::xjdome25_slidermw(uint16 argc, uint16 *argv) {
@@ -1784,11 +1787,11 @@ void RivenExternal::xpisland25_opencard(uint16 argc, uint16 *argv) {
}
void RivenExternal::xpisland25_resetsliders(uint16 argc, uint16 *argv) {
- resetDomeSliders(58, 10, 6);
+ resetDomeSliders(10, 6);
}
void RivenExternal::xpisland25_slidermd(uint16 argc, uint16 *argv) {
- dragDomeSlider(58, 10, 31, 5, 6);
+ dragDomeSlider(10, 31, 5, 6);
}
void RivenExternal::xpisland25_slidermw(uint16 argc, uint16 *argv) {
@@ -2168,11 +2171,11 @@ void RivenExternal::xtisland5056_opencard(uint16 argc, uint16 *argv) {
}
void RivenExternal::xtisland5056_resetsliders(uint16 argc, uint16 *argv) {
- resetDomeSliders(_vm->getFeatures() & GF_DVD ? 813 : 798, 37, 3);
+ resetDomeSliders(37, 3);
}
void RivenExternal::xtisland5056_slidermd(uint16 argc, uint16 *argv) {
- dragDomeSlider(_vm->getFeatures() & GF_DVD ? 813 : 798, 37, 29, 30, 3);
+ dragDomeSlider(37, 29, 30, 3);
}
void RivenExternal::xtisland5056_slidermw(uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/riven_external.h b/engines/mohawk/riven_external.h
index d39bc3532f..49cafb6b4a 100644
--- a/engines/mohawk/riven_external.h
+++ b/engines/mohawk/riven_external.h
@@ -65,11 +65,11 @@ private:
void runCredits(uint16 video);
void runDomeCheck();
void runDomeButtonMovie();
- void resetDomeSliders(uint16 bitmapId, uint16 soundId, uint16 startHotspot);
+ void resetDomeSliders(uint16 soundId, uint16 startHotspot);
void checkDomeSliders(uint16 resetSlidersHotspot, uint16 openDomeHotspot);
void checkSliderCursorChange(uint16 startHotspot);
- void dragDomeSlider(uint16 bitmapId, uint16 soundId, uint16 resetSlidersHotspot, uint16 openDomeHotspot, uint16 startHotspot);
- void drawDomeSliders(uint16 bitmapId, uint16 startHotspot);
+ void dragDomeSlider(uint16 soundId, uint16 resetSlidersHotspot, uint16 openDomeHotspot, uint16 startHotspot);
+ void drawDomeSliders(uint16 startHotspot);
void drawMarbles();
void setMarbleHotspots();