aboutsummaryrefslogtreecommitdiff
path: root/engines/voyeur
diff options
context:
space:
mode:
authorPaul Gilbert2013-12-25 16:40:46 +1100
committerPaul Gilbert2013-12-25 16:40:46 +1100
commit754601bbab9e08daca0f9bb43776a50cecc70520 (patch)
treea9cd7dcf80ac0c8dcfee7d95112142368ef8d4a1 /engines/voyeur
parent562df7ede10f8340faf92f9c47d0414467b03852 (diff)
downloadscummvm-rg350-754601bbab9e08daca0f9bb43776a50cecc70520.tar.gz
scummvm-rg350-754601bbab9e08daca0f9bb43776a50cecc70520.tar.bz2
scummvm-rg350-754601bbab9e08daca0f9bb43776a50cecc70520.zip
VOYEUR: Better implementation of rect resources
Diffstat (limited to 'engines/voyeur')
-rw-r--r--engines/voyeur/events.h2
-rw-r--r--engines/voyeur/files.cpp57
-rw-r--r--engines/voyeur/files.h12
-rw-r--r--engines/voyeur/files_threads.cpp11
-rw-r--r--engines/voyeur/voyeur.cpp4
-rw-r--r--engines/voyeur/voyeur_game.cpp16
6 files changed, 71 insertions, 31 deletions
diff --git a/engines/voyeur/events.h b/engines/voyeur/events.h
index 3c7d202c90..5a94434d78 100644
--- a/engines/voyeur/events.h
+++ b/engines/voyeur/events.h
@@ -127,7 +127,7 @@ public:
int _field4380;
int _field4382;
int _videoEventId;
- byte *_field4386;
+ RectResource *_viewBounds;
int _curICF0;
int _curICF1;
int _fadeICF0;
diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp
index 69256aacb2..3b90e52294 100644
--- a/engines/voyeur/files.cpp
+++ b/engines/voyeur/files.cpp
@@ -453,6 +453,9 @@ BVoyBoltFile::BVoyBoltFile(BoltFilesState &state): BoltFile("bvoy.blt", state) {
void BVoyBoltFile::initResource(int resType) {
switch (resType) {
+ case 2:
+ sInitRect();
+ break;
case 8:
sInitPic();
break;
@@ -521,6 +524,11 @@ void BVoyBoltFile::initSoundMap() {
initDefault();
}
+void BVoyBoltFile::sInitRect() {
+ _state._curMemberPtr->_data = _state.decompress(NULL, 8, _state._curMemberPtr->_mode);
+ _state._curMemberPtr->_rectResource = new RectResource(_state, _state._curMemberPtr->_data);
+}
+
void BVoyBoltFile::sInitPic() {
// Read in the header data
_state._curMemberPtr->_data = _state.decompress(NULL, 24, _state._curMemberPtr->_mode);
@@ -627,17 +635,20 @@ void BoltGroup::unload() {
/*------------------------------------------------------------------------*/
BoltEntry::BoltEntry(Common::SeekableReadStream *f): _file(f) {
- _data = NULL;
- _picResource = NULL;
- _viewPortResource = NULL;
- _viewPortListResource = NULL;
- _fontResource = NULL;
- _fontInfoResource = NULL;
- _cMapResource = NULL;
- _vInitCyclResource = NULL;
- _ptrResource = NULL;
- _controlResource = NULL;
- _threadResource = NULL;
+ _data = nullptr;
+ _rectResource = nullptr;
+ _picResource = nullptr;
+ _viewPortResource = nullptr;
+ _viewPortListResource = nullptr;
+ _fontResource = nullptr;
+ _fontInfoResource = nullptr;
+ _cMapResource = nullptr;
+ _vInitCyclResource = nullptr;
+ _ptrResource = nullptr;
+ _controlResource = nullptr;
+ _vInitCyclResource = nullptr;
+ _cycleResource = nullptr;
+ _threadResource = nullptr;
byte buffer[16];
_file->read(&buffer[0], 16);
@@ -651,6 +662,7 @@ BoltEntry::BoltEntry(Common::SeekableReadStream *f): _file(f) {
BoltEntry::~BoltEntry() {
delete[] _data;
+ delete _rectResource;
delete _picResource;
delete _viewPortResource;
delete _viewPortListResource;
@@ -658,6 +670,7 @@ BoltEntry::~BoltEntry() {
delete _fontInfoResource;
delete _cMapResource;
delete _vInitCyclResource;
+ delete _cycleResource;
delete _ptrResource;
delete _controlResource;
}
@@ -671,10 +684,26 @@ void BoltEntry::load() {
* Returns true if the given bolt entry has an attached resource
*/
bool BoltEntry::hasResource() const {
- return _picResource || _viewPortResource || _viewPortListResource
+ return _rectResource || _picResource || _viewPortResource || _viewPortListResource
|| _fontResource || _fontInfoResource || _cMapResource
- || _vInitCyclResource || _ptrResource || _controlResource
- || _threadResource;
+ || _vInitCyclResource || _cycleResource
+ || _ptrResource || _controlResource || _threadResource;
+}
+
+/*------------------------------------------------------------------------*/
+
+RectResource::RectResource(BoltFilesState &state, const byte *src) {
+ left = READ_LE_UINT16(src);
+ top = READ_LE_UINT16(src + 2);
+ setWidth(READ_LE_UINT16(src + 4));
+ setHeight(READ_LE_UINT16(src + 6));
+}
+
+RectResource::RectResource(int x1, int y1, int x2, int y2) {
+ left = x1;
+ top = y1;
+ right = x2;
+ bottom = y2;
}
/*------------------------------------------------------------------------*/
diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h
index 7c004a526f..4440490e12 100644
--- a/engines/voyeur/files.h
+++ b/engines/voyeur/files.h
@@ -35,6 +35,7 @@ class VoyeurEngine;
class BoltFile;
class BoltGroup;
class BoltEntry;
+class RectResource;
class PictureResource;
class ViewPortResource;
class ViewPortListResource;
@@ -43,6 +44,7 @@ class CMapResource;
class VInitCyclResource;
class PtrResource;
class ControlResource;
+class CycleResource;
class ThreadResource;
#define DECOMPRESS_SIZE 0x7000
@@ -137,6 +139,7 @@ public:
class BVoyBoltFile: public BoltFile {
private:
// initType method table
+ void sInitRect();
void sInitPic();
void vInitCMap();
void vInitCycl();
@@ -195,6 +198,7 @@ public:
byte *_data;
// bvoy.blt resource types
+ RectResource *_rectResource;
PictureResource *_picResource;
ViewPortResource *_viewPortResource;
ViewPortListResource *_viewPortListResource;
@@ -202,6 +206,7 @@ public:
FontInfoResource *_fontInfoResource;
CMapResource *_cMapResource;
VInitCyclResource *_vInitCyclResource;
+ CycleResource *_cycleResource; // TODO: Dup with VInit?
// stampblt.blt resource types
PtrResource *_ptrResource;
@@ -229,6 +234,13 @@ public:
byte *fload(const Common::String &filename, int *size = NULL);
};
+class RectResource: public Common::Rect {
+public:
+ RectResource(BoltFilesState &state, const byte *src);
+ RectResource(int xp, int yp, int width, int height);
+ virtual ~RectResource() {}
+};
+
enum DisplayFlag { DISPFLAG_1 = 1, DISPFLAG_2 = 2, DISPFLAG_4 = 4, DISPFLAG_8 = 8,
DISPFLAG_10 = 0x10, DISPFLAG_20 = 0x20, DISPFLAG_40 = 0x40, DISPFLAG_80 = 0x80,
DISPFLAG_100 = 0x100, DISPFLAG_200 = 0x200, DISPFLAG_400 = 0x400,
diff --git a/engines/voyeur/files_threads.cpp b/engines/voyeur/files_threads.cpp
index f2b5955b1a..43bebf3564 100644
--- a/engines/voyeur/files_threads.cpp
+++ b/engines/voyeur/files_threads.cpp
@@ -1052,7 +1052,7 @@ int ThreadResource::doApt() {
loadTheApt();
_vm->_playStamp2 = 151;
- _vm->_voy._field4386 = _vm->_bVoy->memberAddr(_vm->_playStamp1);
+ _vm->_voy._viewBounds = _vm->_bVoy->boltEntry(_vm->_playStamp1)._rectResource;
byte *hotspotsP = _vm->_bVoy->memberAddr(_vm->_playStamp1 + 1);
_vm->_eventsManager.getMouseInfo();
@@ -1188,9 +1188,8 @@ void ThreadResource::doRoom() {
PictureResource *pic1 = vm._bVoy->boltEntry(vm._playStamp1 + 2)._picResource;
PictureResource *pic2 = vm._bVoy->boltEntry(vm._playStamp1 + 3)._picResource;
- byte arr[10];
- strcpy((char *)&arr[0], "0");
- voy._field4386 = &arr[0];
+ RectResource viewBounds(48, 38, 336, 202);
+ voy._viewBounds = &viewBounds;
vm._eventsManager.getMouseInfo();
vm._eventsManager.setMousePos(Common::Point(192, 120));
@@ -1347,7 +1346,7 @@ void ThreadResource::doRoom() {
voy._field478 = 1;
vm._eventsManager.incrementTime(1);
- voy._field4386 = 0;
+ voy._viewBounds = nullptr;
voy._field437E = 0;
vm.makeViewFinderP();
@@ -1707,7 +1706,7 @@ void ThreadResource::freeTheApt() {
(*_vm->_graphicsManager._vPort)->setupViewPort(nullptr);
_vm->_bVoy->freeBoltGroup(_vm->_playStamp1);
_vm->_playStamp1 = -1;
- _vm->_voy._field4386 = 0;
+ _vm->_voy._viewBounds = nullptr;
}
void ThreadResource::doAptAnim(int mode) {
diff --git a/engines/voyeur/voyeur.cpp b/engines/voyeur/voyeur.cpp
index 90ea87339d..ab8f3cf6a0 100644
--- a/engines/voyeur/voyeur.cpp
+++ b/engines/voyeur/voyeur.cpp
@@ -265,7 +265,7 @@ bool VoyeurEngine::doLock() {
lock.getThePassword();
_voy._field4380 = lock.fieldC;
- _voy._field4386 = _bVoy->memberAddr(0x704);
+ _voy._viewBounds = _bVoy->boltEntry(0x704)._rectResource;
Common::String password = lock._password;
cursorPic = _bVoy->getPictureResource(0x702);
@@ -422,7 +422,7 @@ bool VoyeurEngine::doLock() {
lock._password = displayString;
lock.saveThePassword();
- _voy._field4386 = NULL;
+ _voy._viewBounds = nullptr;
_bVoy->freeBoltGroup(0x700);
}
diff --git a/engines/voyeur/voyeur_game.cpp b/engines/voyeur/voyeur_game.cpp
index 2be982b2b9..811f386835 100644
--- a/engines/voyeur/voyeur_game.cpp
+++ b/engines/voyeur/voyeur_game.cpp
@@ -201,7 +201,7 @@ void VoyeurEngine::playStamp() {
} while (flag);
}
- _voy._field4386 = 0;
+ _voy._viewBounds = nullptr;
closeStamp();
_stampLibPtr->freeBoltGroup(0);
delete _stampLibPtr;
@@ -243,7 +243,7 @@ void VoyeurEngine::reviewTape() {
bool breakFlag = false;
while (!shouldQuit() && !breakFlag) {
- _voy._field4386 = _bVoy->memberAddr(0x907);
+ _voy._viewBounds = _bVoy->boltEntry(0x907)._rectResource;
byte *dataP = _bVoy->memberAddr(0x906);
int varA = READ_LE_UINT16(dataP);
_graphicsManager._backColors = _bVoy->boltEntry(0x902)._cMapResource;
@@ -411,11 +411,11 @@ void VoyeurEngine::reviewTape() {
_eventsManager.getMouseInfo();
foundIndex = 999;
}
- } else if ((_voy._field478 & 0x40) && READ_LE_UINT16(_voy._field4386) == pt.x &&
- READ_LE_UINT16(_voy._field4386 + 6) == pt.y) {
+ } else if ((_voy._field478 & 0x40) && _voy._viewBounds->left == pt.x &&
+ _voy._viewBounds->bottom == pt.y) {
foundIndex = 999;
- } else if ((_voy._field478 & 0x40) && READ_LE_UINT16(_voy._field4386) == pt.x &&
- READ_LE_UINT16(_voy._field4386 + 2) == pt.y) {
+ } else if ((_voy._field478 & 0x40) && _voy._viewBounds->left == pt.x &&
+ _voy._viewBounds->top == pt.y) {
foundIndex = 998;
} else {
_eventsManager.setCursorColor(128, (foundIndex == -1) ? 0 : 1);
@@ -471,7 +471,7 @@ void VoyeurEngine::reviewTape() {
}
pt = _eventsManager.getMousePos();
- if (_voy._incriminate && READ_LE_UINT16(_voy._field4386) == pt.x &&
+ if (_voy._incriminate && _voy._viewBounds->left == pt.x &&
(_voy._field478 & 0x40) && _voy._fadeFunc) {
WRITE_LE_UINT32(_controlPtr->_ptr + 4, (pt.y / 60) + 1);
foundIndex = -1;
@@ -703,7 +703,7 @@ void VoyeurEngine::initIFace(){
doScroll(_eventsManager.getMousePos());
- _voy._field4386 = _bVoy->memberAddr(_playStamp1);
+ _voy._viewBounds = _bVoy->boltEntry(_playStamp1)._rectResource;
// Note: the original did two loops to preload members here, which is
// redundant for ScummVM, since computers are faster these days, and