aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-01-31 21:58:03 -0500
committerPaul Gilbert2014-01-31 21:58:03 -0500
commitf31a422ddfb97efbdec5d0f69b4c4e81b571b5f7 (patch)
tree628a379aca546dd5465dfba67877c29049ec63eb /engines
parentb4ab7c33578dfe35d2d19ea06c2b0d290aa49f59 (diff)
downloadscummvm-rg350-f31a422ddfb97efbdec5d0f69b4c4e81b571b5f7.tar.gz
scummvm-rg350-f31a422ddfb97efbdec5d0f69b4c4e81b571b5f7.tar.bz2
scummvm-rg350-f31a422ddfb97efbdec5d0f69b4c4e81b571b5f7.zip
VOYEUR: Add support for the extended rects used by room displays
Diffstat (limited to 'engines')
-rw-r--r--engines/voyeur/files.cpp51
-rw-r--r--engines/voyeur/files.h17
-rw-r--r--engines/voyeur/files_threads.cpp18
-rw-r--r--engines/voyeur/voyeur_game.cpp11
4 files changed, 59 insertions, 38 deletions
diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp
index a2177230c6..fe77d2f9e9 100644
--- a/engines/voyeur/files.cpp
+++ b/engines/voyeur/files.cpp
@@ -251,7 +251,7 @@ BoltGroup *BoltFile::getBoltGroup(uint16 id, bool process) {
if (!_state._curGroupPtr->_loaded) {
// Load the group index
- _state._curGroupPtr->load();
+ _state._curGroupPtr->load(id & 0xff00);
}
if (_state._curGroupPtr->_callInitGro)
@@ -266,7 +266,7 @@ BoltGroup *BoltFile::getBoltGroup(uint16 id, bool process) {
}
} else if (!_state._curGroupPtr->_processed) {
_state._curGroupPtr->_processed = true;
- _state._curGroupPtr->load();
+ _state._curGroupPtr->load(id & 0xff00);
}
resolveAll();
@@ -397,7 +397,7 @@ byte *BoltFile::getBoltMember(uint32 id) {
// Get the group, and load it's entry list if not already loaded
_state._curGroupPtr = &_groups[(id >> 8) & 0xff];
if (!_state._curGroupPtr->_loaded)
- _state._curGroupPtr->load();
+ _state._curGroupPtr->load(id & 0xff00);
// Get the entry
_state._curMemberPtr = &_state._curGroupPtr->_entries[id & 0xff];
@@ -529,9 +529,15 @@ void BVoyBoltFile::sInitRect() {
_state._curMemberPtr->_data = _state.decompress(NULL, _state._curMemberPtr->_size,
_state._curMemberPtr->_mode);
- if ((_state._curMemberPtr->_size % 8) == 0 || (_state._curMemberPtr->_size % 8) == 2)
- _state._curMemberPtr->_rectResource = new RectResource(_state._curMemberPtr->_data,
- _state._curMemberPtr->_size);
+ // Check whether the resouce Id is in the list of extended rects
+ bool isExtendedRects = false;
+ for (int i = 0; i < 49 && !isExtendedRects; ++i)
+ isExtendedRects = RESOLVE_TABLE[i] == (_state._curMemberPtr->_id & 0xff00);
+
+ int rectSize = isExtendedRects ? 12 : 8;
+ if ((_state._curMemberPtr->_size % rectSize) == 0 || (_state._curMemberPtr->_size % rectSize) == 2)
+ _state._curMemberPtr->_rectResource = new RectResource(_state._curMemberPtr->_data,
+ _state._curMemberPtr->_size, isExtendedRects);
}
void BVoyBoltFile::sInitPic() {
@@ -619,12 +625,12 @@ BoltGroup::BoltGroup(Common::SeekableReadStream *f): _file(f) {
BoltGroup::~BoltGroup() {
}
-void BoltGroup::load() {
+void BoltGroup::load(uint16 groupId) {
_file->seek(_fileOffset);
// Read the entries
for (int i = 0; i < _count; ++i)
- _entries.push_back(BoltEntry(_file));
+ _entries.push_back(BoltEntry(_file, groupId + i));
_loaded = true;
}
@@ -639,7 +645,7 @@ void BoltGroup::unload() {
/*------------------------------------------------------------------------*/
-BoltEntry::BoltEntry(Common::SeekableReadStream *f): _file(f) {
+BoltEntry::BoltEntry(Common::SeekableReadStream *f, uint16 id): _file(f), _id(id) {
_data = nullptr;
_rectResource = nullptr;
_picResource = nullptr;
@@ -660,7 +666,7 @@ BoltEntry::BoltEntry(Common::SeekableReadStream *f): _file(f) {
_field1 = buffer[1];
_initMethod = buffer[3];
_xorMask = buffer[4] & 0xff; // TODO: Is this right??
- _size = READ_LE_UINT32(&buffer[4]);
+ _size = READ_LE_UINT32(&buffer[4]) & 0xffffff;
_fileOffset = READ_LE_UINT32(&buffer[8]);
}
@@ -695,25 +701,36 @@ bool BoltEntry::hasResource() const {
/*------------------------------------------------------------------------*/
-RectResource::RectResource(const byte *src, int size) {
+RectEntry::RectEntry(int x1, int y1, int x2, int y2, int arrIndex, int count):
+ Common::Rect(x1, y1, x2, y2), _arrIndex(arrIndex), _count(count) {
+}
+
+/*------------------------------------------------------------------------*/
+
+RectResource::RectResource(const byte *src, int size, bool isExtendedRects) {
int count;
- if ((size % 8) == 2) {
+ int rectSize = isExtendedRects ? 12 : 8;
+ if ((size % rectSize) == 2) {
count = READ_LE_UINT16(src);
src += 2;
} else {
- count = size / 8;
+ count = size / rectSize;
}
for (int i = 0; i < count; ++i, src += 8) {
+ int arrIndex = 0, count = 0;
+ if (isExtendedRects) {
+ arrIndex = READ_LE_UINT16(src);
+ count = READ_LE_UINT16(src + 2);
+ src += 4;
+ }
+
int x1 = READ_LE_UINT16(src);
int y1 = READ_LE_UINT16(src + 2);
int x2 = READ_LE_UINT16(src + 4);
int y2 = READ_LE_UINT16(src + 6);
- if (x2 >= x1 && y2 >= y1)
- _entries.push_back(Common::Rect(x1, y1, x2, y2));
- else
- _entries.push_back(Common::Rect());
+ _entries.push_back(RectEntry(x1, y1, x2, y2, arrIndex, count));
}
left = _entries[0].left;
diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h
index cc30d0a493..97ade46b1f 100644
--- a/engines/voyeur/files.h
+++ b/engines/voyeur/files.h
@@ -179,7 +179,7 @@ public:
BoltGroup(Common::SeekableReadStream *f);
virtual ~BoltGroup();
- void load();
+ void load(uint16 groupId);
void unload();
};
@@ -188,6 +188,7 @@ class BoltEntry {
private:
Common::SeekableReadStream *_file;
public:
+ uint16 _id;
byte _mode;
byte _field1;
byte _initMethod;
@@ -211,7 +212,7 @@ public:
ControlResource *_controlResource;
ThreadResource *_threadResource;
public:
- BoltEntry(Common::SeekableReadStream *f);
+ BoltEntry(Common::SeekableReadStream *f, uint16 id);
virtual ~BoltEntry();
void load();
@@ -232,11 +233,19 @@ public:
byte *fload(const Common::String &filename, int *size = NULL);
};
+class RectEntry: public Common::Rect {
+public:
+ int _arrIndex;
+ int _count;
+
+ RectEntry(int x1, int y1, int x2, int y2, int arrIndex, int count);
+};
+
class RectResource: public Common::Rect {
public:
- Common::Array<Common::Rect> _entries;
+ Common::Array<RectEntry> _entries;
public:
- RectResource(const byte *src, int size);
+ RectResource(const byte *src, int size, bool isExtendedRects);
RectResource(int xp, int yp, int width, int height);
virtual ~RectResource() {}
};
diff --git a/engines/voyeur/files_threads.cpp b/engines/voyeur/files_threads.cpp
index da4ae551ba..03e393936a 100644
--- a/engines/voyeur/files_threads.cpp
+++ b/engines/voyeur/files_threads.cpp
@@ -1033,7 +1033,7 @@ int ThreadResource::doApt() {
_vm->_currentVocId = 151;
_vm->_voy._viewBounds = _vm->_bVoy->boltEntry(_vm->_playStampGroupId)._rectResource;
- Common::Array<Common::Rect> &hotspots = _vm->_bVoy->boltEntry(
+ Common::Array<RectEntry> &hotspots = _vm->_bVoy->boltEntry(
_vm->_playStampGroupId + 1)._rectResource->_entries;
_vm->_eventsManager.getMouseInfo();
@@ -1169,8 +1169,7 @@ void ThreadResource::doRoom() {
voy._field437C = 0;
voy._field437E = 1;
- byte *dataP = vm._bVoy->memberAddr(vm._playStampGroupId + 4);
- int count = READ_LE_UINT16(dataP);
+ Common::Array<RectEntry> &hotspots = vm._bVoy->boltEntry(vm._playStampGroupId + 4)._rectResource->_entries;
int i4e4 = -1;
PictureResource *pic1 = vm._bVoy->boltEntry(vm._playStampGroupId + 2)._picResource;
@@ -1209,12 +1208,9 @@ void ThreadResource::doRoom() {
if (voy._computerTextId != -1 && voy._rect4E4.contains(pt))
i4e4 = 999;
- for (int idx = 0; idx < count; ++idx) {
- if (pt.x > READ_LE_UINT16(dataP + idx * 12 + 6) &&
- pt.x < READ_LE_UINT16(dataP + idx * 12 + 10) &&
- pt.y > READ_LE_UINT16(dataP + idx * 12 + 8) &&
- pt.y < READ_LE_UINT16(dataP + idx * 12 + 12)) {
- int arrIndex = READ_LE_UINT16(dataP + idx * 12 + 2);
+ for (uint idx = 0; idx < hotspots.size(); ++idx) {
+ if (hotspots[idx].contains(pt)) {
+ int arrIndex = hotspots[idx]._arrIndex;
if (voy._arr7[arrIndex - 1] == 1) {
i4e4 = idx;
break;
@@ -1289,7 +1285,7 @@ void ThreadResource::doRoom() {
//vm._bVoy->freeBoltGroup(vm._playStampGroupId);
//vm._bVoy->getBoltGroup(vm._playStampGroupId);
- dataP = vm._bVoy->memberAddr(vm._playStampGroupId + 4);
+ hotspots = vm._bVoy->boltEntry(vm._playStampGroupId + 4)._rectResource->_entries;
pic1 = vm._bVoy->boltEntry(vm._playStampGroupId + 2)._picResource;
pic2 = vm._bVoy->boltEntry(vm._playStampGroupId + 3)._picResource;
vm._graphicsManager._backColors = vm._bVoy->boltEntry(
@@ -1392,7 +1388,7 @@ int ThreadResource::doInterface() {
_vm->_eventsManager.getMouseInfo();
_vm->initIFace();
- Common::Array<Common::Rect> *hotspots = &_vm->_bVoy->boltEntry(
+ Common::Array<RectEntry> *hotspots = &_vm->_bVoy->boltEntry(
_vm->_playStampGroupId + 1)._rectResource->_entries;
_vm->_currentVocId = 151 - _vm->getRandomNumber(5);
_vm->_voy._vocSecondsOffset = _vm->getRandomNumber(29);
diff --git a/engines/voyeur/voyeur_game.cpp b/engines/voyeur/voyeur_game.cpp
index 6844fadfd3..939bc350df 100644
--- a/engines/voyeur/voyeur_game.cpp
+++ b/engines/voyeur/voyeur_game.cpp
@@ -434,7 +434,7 @@ void VoyeurEngine::reviewTape() {
bool breakFlag = false;
while (!shouldQuit() && !breakFlag) {
_voy._viewBounds = _bVoy->boltEntry(0x907)._rectResource;
- Common::Array<Common::Rect> &hotspots = _bVoy->boltEntry(0x906)._rectResource->_entries;
+ Common::Array<RectEntry> &hotspots = _bVoy->boltEntry(0x906)._rectResource->_entries;
_graphicsManager._backColors = _bVoy->boltEntry(0x902)._cMapResource;
_graphicsManager._backgroundPage = _bVoy->boltEntry(0x901)._picResource;
@@ -926,7 +926,7 @@ void VoyeurEngine::playAVideoEvent(int eventIndex) {
int VoyeurEngine::getChooseButton() {
int prevIndex = -2;
- Common::Array<Common::Rect> &hotspots = _bVoy->boltEntry(_playStampGroupId
+ Common::Array<RectEntry> &hotspots = _bVoy->boltEntry(_playStampGroupId
+ 6)._rectResource->_entries;
int selectedIndex = -1;
@@ -1348,8 +1348,8 @@ void VoyeurEngine::doEvidDisplay(int evidId, int eventId) {
_eventsManager.delay(1);
_bVoy->freeBoltMember(_voy._field47A + evidId * 2 + 1);
- byte *dataP = _bVoy->memberAddr(_playStampGroupId + 4);
- int count = (int16)READ_LE_UINT16(dataP + evidId * 12 + 4);
+ Common::Array<RectEntry> &hotspots = _bVoy->boltEntry(_playStampGroupId + 4)._rectResource->_entries;
+ int count = hotspots[evidId]._count;
if (count > 0) {
for (int idx = 1; idx <= count; ++idx) {
@@ -1406,8 +1406,7 @@ void VoyeurEngine::doEvidDisplay(int evidId, int eventId) {
if (eventId == 999)
_voy.addEvidEventEnd(evidIdx);
- count = (int16)READ_LE_UINT16(dataP + evidId * 12 + 4);
- for (int idx = 1; idx <= count; ++idx) {
+ for (int idx = 1; idx <= hotspots[evidId]._count; ++idx) {
_bVoy->freeBoltMember(_voy._field47A + (evidId + idx) * 2);
_bVoy->freeBoltMember(_voy._field47A + (evidId + idx) * 2 + 1);
}