aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2013-12-08 19:25:40 -0500
committerPaul Gilbert2013-12-08 19:25:40 -0500
commit7ccc9a3fabc7138ab45dfe1bf987ac4e07739b50 (patch)
tree957315e1a918442346f7aaf2fff9bd12350a6969 /engines
parent96b1fb8601ebdda0a6bd8220d55baf3386d1551a (diff)
downloadscummvm-rg350-7ccc9a3fabc7138ab45dfe1bf987ac4e07739b50.tar.gz
scummvm-rg350-7ccc9a3fabc7138ab45dfe1bf987ac4e07739b50.tar.bz2
scummvm-rg350-7ccc9a3fabc7138ab45dfe1bf987ac4e07739b50.zip
VOYEUR: Moved stm methods into ThreadResource class
Diffstat (limited to 'engines')
-rw-r--r--engines/voyeur/files.cpp49
-rw-r--r--engines/voyeur/files.h12
-rw-r--r--engines/voyeur/voyeur.cpp1
-rw-r--r--engines/voyeur/voyeur.h9
-rw-r--r--engines/voyeur/voyeur_game.cpp57
5 files changed, 68 insertions, 60 deletions
diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp
index f9fce61f8d..84f0df81ef 100644
--- a/engines/voyeur/files.cpp
+++ b/engines/voyeur/files.cpp
@@ -1307,10 +1307,57 @@ VInitCyclResource::VInitCyclResource(BoltFilesState &state, const byte *src) {
/*------------------------------------------------------------------------*/
-ThreadResource::ThreadResource(BoltFilesState &state, const byte *src) {
+int ThreadResource::_stampFlags = 0;
+int ThreadResource::_useCount[8];
+
+ThreadResource::ThreadResource(BoltFilesState &state, const byte *src):
+ _vm(state._vm) {
_flags = READ_LE_UINT16(&src[8]);
}
+bool ThreadResource::loadAStack(int idx) {
+ if (_stampFlags & 1) {
+ unloadAStack(_controlIndex);
+ if (!_useCount[idx]) {
+ BoltEntry &boltEntry = _vm->_stampLibPtr->boltEntry(_vm->_controlPtr->_memberIds[idx]);
+ if (!boltEntry._data)
+ return false;
+
+ _vm->_controlPtr->_entries[idx] = boltEntry._data;
+ }
+
+ ++_useCount[idx];
+ }
+
+ _ctlPtr = _vm->_controlPtr->_entries[idx];
+ return true;
+}
+
+void ThreadResource::unloadAStack(int idx) {
+ if ((_stampFlags & 1) && _useCount[idx]) {
+ if (--_useCount[idx] == 0) {
+ _vm->_stampLibPtr->freeBoltMember(_vm->_controlPtr->_memberIds[idx]);
+ }
+ }
+}
+
+void ThreadResource::doState() {
+ warning("TODO: stm_doState");
+}
+
+void ThreadResource::unloadAllStacks(VoyeurEngine *vm) {
+ if (_stampFlags & 1) {
+ for (int i = 0; i < 8; ++i) {
+ if (_useCount[i])
+ vm->_stampLibPtr->freeBoltMember(vm->_controlPtr->_memberIds[i]);
+ }
+ }
+}
+
+void ThreadResource::initUseCount() {
+ Common::fill(&_useCount[0], &_useCount[8], 0);
+}
+
/*------------------------------------------------------------------------*/
PtrResource::PtrResource(BoltFilesState &state, const byte *src) {
diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h
index 7ea7dead91..3ce9d4c2f6 100644
--- a/engines/voyeur/files.h
+++ b/engines/voyeur/files.h
@@ -414,6 +414,14 @@ public:
class ThreadResource {
public:
+ static int _stampFlags;
+ static int _useCount[8];
+
+ static void initUseCount();
+ static void unloadAllStacks(VoyeurEngine *vm);
+public:
+ VoyeurEngine *_vm;
+
int _field0;
int _controlIndex;
int _field4, _field6;
@@ -424,6 +432,10 @@ public:
public:
ThreadResource(BoltFilesState &state, const byte *src);
virtual ~ThreadResource() {}
+
+ bool loadAStack(int idx);
+ void unloadAStack(int idx);
+ void doState();
};
} // End of namespace Voyeur
diff --git a/engines/voyeur/voyeur.cpp b/engines/voyeur/voyeur.cpp
index 000012c899..7312728c24 100644
--- a/engines/voyeur/voyeur.cpp
+++ b/engines/voyeur/voyeur.cpp
@@ -41,7 +41,6 @@ VoyeurEngine::VoyeurEngine(OSystem *syst, const VoyeurGameDescription *gameDesc)
_bVoy = NULL;
_iForceDeath = -1;
_controlPtr = NULL;
- _stampFlags = 0;
initialiseManagers();
}
diff --git a/engines/voyeur/voyeur.h b/engines/voyeur/voyeur.h
index 549a335416..772343b00a 100644
--- a/engines/voyeur/voyeur.h
+++ b/engines/voyeur/voyeur.h
@@ -84,12 +84,7 @@ private:
void playStamp();
void initStamp();
void closeStamp();
- void initUseCount();
- void initThreadStruct(ThreadResource *thread, int v1, int idx);
- bool stm_loadAStack(ThreadResource *thread, int idx);
- void stm_unloadAStack(int idx);
- void stm_unloadAllStacks();
- void stm_doState(ThreadResource *thread);
+ void initThreadStruct(ThreadResource *thread, int idx, int v3);
protected:
// Engine APIs
virtual Common::Error run();
@@ -108,8 +103,6 @@ public:
ControlResource *_controlPtr;
byte *_stampData;
BoltGroup *_stackGroupPtr;
- int _stampFlags;
- int _stm_useCount[8];
public:
VoyeurEngine(OSystem *syst, const VoyeurGameDescription *gameDesc);
virtual ~VoyeurEngine();
diff --git a/engines/voyeur/voyeur_game.cpp b/engines/voyeur/voyeur_game.cpp
index ee7ef66c6d..adaff87672 100644
--- a/engines/voyeur/voyeur_game.cpp
+++ b/engines/voyeur/voyeur_game.cpp
@@ -65,72 +65,29 @@ void VoyeurEngine::playStamp() {
}
void VoyeurEngine::initStamp() {
- _stampFlags &= ~1;
+ ThreadResource::_stampFlags &= ~1;
_stackGroupPtr = _controlGroupPtr;
if (!_controlPtr->_entries[0])
error("No control entries");
- initUseCount();
+ ThreadResource::initUseCount();
}
void VoyeurEngine::closeStamp() {
- stm_unloadAllStacks();
+ ThreadResource::unloadAllStacks(this);
}
-void VoyeurEngine::initUseCount() {
- Common::fill(&_stm_useCount[0], &_stm_useCount[8], 0);
-}
-
-void VoyeurEngine::initThreadStruct(ThreadResource *thread, int v1, int idx) {
+void VoyeurEngine::initThreadStruct(ThreadResource *thread, int idx, int v3) {
thread->_controlIndex = -1;
- if (stm_loadAStack(thread, idx)) {
+ if (thread->loadAStack(idx)) {
thread->_field4 = thread->_field6 = -1;
- thread->_field0 = idx;
+ thread->_field0 = v3;
thread->_field3A = -1;
thread->_field3E = -1;
- stm_doState(thread);
- }
-}
-
-bool VoyeurEngine::stm_loadAStack(ThreadResource *thread, int idx) {
- if (_stampFlags & 1) {
- stm_unloadAStack(thread->_controlIndex);
- if (!_stm_useCount[idx]) {
- BoltEntry &boltEntry = _stampLibPtr->boltEntry(_controlPtr->_memberIds[idx]);
- if (!boltEntry._data)
- return false;
-
- _controlPtr->_entries[idx] = boltEntry._data;
- }
-
- ++_stm_useCount[idx];
- }
-
- thread->_ctlPtr = _controlPtr->_entries[idx];
- return true;
-}
-
-void VoyeurEngine::stm_unloadAStack(int idx) {
- if ((_stampFlags & 1) && _stm_useCount[idx]) {
- if (--_stm_useCount[idx] == 0) {
- _stampLibPtr->freeBoltMember(_controlPtr->_memberIds[idx]);
- }
- }
-}
-
-void VoyeurEngine::stm_unloadAllStacks() {
- if (_stampFlags & 1) {
- for (int i = 0; i < 8; ++i) {
- if (_stm_useCount[i])
- _stampLibPtr->freeBoltMember(_controlPtr->_memberIds[i]);
- }
+ thread->doState();
}
}
-void VoyeurEngine::stm_doState(ThreadResource *thread) {
- warning("TODO: stm_doState");
-}
-
} // End of namespace Voyeur