aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2013-03-24 22:56:06 +0100
committerStrangerke2013-03-24 22:56:06 +0100
commitac338c3517d85156e83884164d378c3bf76851e5 (patch)
tree1a2e3df43d79fae887b130a57d95c6c4ce4ff0af
parent57abce19b1da832f1f108f6aff22e40649572f97 (diff)
downloadscummvm-rg350-ac338c3517d85156e83884164d378c3bf76851e5.tar.gz
scummvm-rg350-ac338c3517d85156e83884164d378c3bf76851e5.tar.bz2
scummvm-rg350-ac338c3517d85156e83884164d378c3bf76851e5.zip
HOPKINS: Some more refactoring in Globals
-rw-r--r--engines/hopkins/files.cpp13
-rw-r--r--engines/hopkins/files.h3
-rw-r--r--engines/hopkins/globals.cpp6
-rw-r--r--engines/hopkins/globals.h8
-rw-r--r--engines/hopkins/graphics.cpp4
-rw-r--r--engines/hopkins/objects.cpp18
-rw-r--r--engines/hopkins/objects.h6
-rw-r--r--engines/hopkins/sound.cpp12
-rw-r--r--engines/hopkins/talk.cpp6
9 files changed, 40 insertions, 36 deletions
diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp
index 78ff7b2535..98cc34422e 100644
--- a/engines/hopkins/files.cpp
+++ b/engines/hopkins/files.cpp
@@ -35,6 +35,9 @@ namespace Hopkins {
FileManager::FileManager(HopkinsEngine *vm) {
_vm = vm;
+
+ _catalogPos = 0;
+ _catalogSize = 0;
}
/**
@@ -196,8 +199,8 @@ byte *FileManager::searchCat(const Common::String &file, CatMode mode) {
if (name == filename) {
// Found entry for file, so get it's details from the catalogue entry
const byte *pData = ptr + offsetVal;
- _vm->_globals->_catalogPos = READ_LE_UINT32(pData + 15);
- _vm->_globals->_catalogSize = READ_LE_UINT32(pData + 19);
+ _catalogPos = READ_LE_UINT32(pData + 15);
+ _catalogSize = READ_LE_UINT32(pData + 19);
matchFlag = true;
}
@@ -215,13 +218,13 @@ byte *FileManager::searchCat(const Common::String &file, CatMode mode) {
if (!f.open(secondaryFilename))
error("CHARGE_FICHIER");
- f.seek(_vm->_globals->_catalogPos);
+ f.seek(_catalogPos);
- byte *catData = _vm->_globals->allocMemory(_vm->_globals->_catalogSize);
+ byte *catData = _vm->_globals->allocMemory(_catalogSize);
if (catData == g_PTRNUL)
error("CHARGE_FICHIER");
- readStream(f, catData, _vm->_globals->_catalogSize);
+ readStream(f, catData, _catalogSize);
f.close();
result = catData;
} else {
diff --git a/engines/hopkins/files.h b/engines/hopkins/files.h
index 145c267935..6d2904a21e 100644
--- a/engines/hopkins/files.h
+++ b/engines/hopkins/files.h
@@ -38,6 +38,9 @@ enum CatMode { RES_INI = 1, RES_REP = 2, RES_LIN = 3, RES_PER = 5,
class FileManager {
public:
+ uint32 _catalogPos;
+ uint32 _catalogSize;
+
HopkinsEngine *_vm;
FileManager(HopkinsEngine *vm);
diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp
index 015ebb1561..a495a809e7 100644
--- a/engines/hopkins/globals.cpp
+++ b/engines/hopkins/globals.cpp
@@ -78,10 +78,8 @@ Globals::Globals(HopkinsEngine *vm) {
Common::fill((byte *)&Liste[i], (byte *)&Liste[i] + sizeof(ListeItem), 0);
for (int i = 0; i < 35; ++i)
Common::fill((byte *)&Liste2[i], (byte *)&Liste2[i] + sizeof(ListeItem), 0);
- for (int i = 0; i < 30; ++i) {
- Common::fill((byte *)&_lockedAnims[i], (byte *)&_lockedAnims[i] + sizeof(LockAnimItem), 0);
+ for (int i = 0; i < 30; ++i)
Common::fill((byte *)&VBob[i], (byte *)&VBob[i] + sizeof(VBobItem), 0);
- }
for (int i = 0; i < 300; ++i)
Common::fill((byte *)&_objectAuthIcons[i], (byte *)&_objectAuthIcons[i] + sizeof(ObjectAuthIcon), 0);
for (int i = 0; i < 25; ++i)
@@ -101,8 +99,6 @@ Globals::Globals(HopkinsEngine *vm) {
_linuxEndDemoFl = false;
_speed = 1;
_curObjectFileNum = 0;
- _catalogPos = 0;
- _catalogSize = 0;
iRegul = 0;
_exitId = 0;
_characterSpriteBuf = 0;
diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h
index 05e563ff40..c1725d5c0c 100644
--- a/engines/hopkins/globals.h
+++ b/engines/hopkins/globals.h
@@ -50,11 +50,6 @@ struct ListeItem {
int _height;
};
-struct LockAnimItem {
- bool _enableFl;
- int _posX;
-};
-
struct VBobItem {
byte *_spriteData;
int _displayMode;
@@ -271,9 +266,6 @@ public:
byte *_optionDialogSpr;
bool _optionDialogFl;
- uint32 _catalogPos;
- uint32 _catalogSize;
- LockAnimItem _lockedAnims[30];
int _oldRouteFromX;
int _oldRouteFromY;
int _oldRouteDestX;
diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp
index 5c65e59c5e..14f23ad06a 100644
--- a/engines/hopkins/graphics.cpp
+++ b/engines/hopkins/graphics.cpp
@@ -310,7 +310,7 @@ void GraphicsManager::loadPCX640(byte *surface, const Common::String &file, byte
// Load PCX from within the PIC resource
if (!f.open("PIC.RES"))
error("Error opening PIC.RES.");
- f.seek(_vm->_globals->_catalogPos);
+ f.seek(_vm->_fileManager->_catalogPos);
} else {
// Load stand alone PCX file
if (!f.open(file))
@@ -1074,7 +1074,7 @@ void GraphicsManager::endDisplayBob() {
}
for (int idx = 1; idx <= 29; ++idx) {
- _vm->_globals->_lockedAnims[idx]._enableFl = false;
+ _vm->_objectsManager->_lockedAnims[idx]._enableFl = false;
}
for (int idx = 1; idx <= 20; ++idx) {
diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp
index 27689af6fe..cd8cc1bcf3 100644
--- a/engines/hopkins/objects.cpp
+++ b/engines/hopkins/objects.cpp
@@ -44,6 +44,10 @@ ObjectsManager::ObjectsManager(HopkinsEngine *vm) {
for (int i = 0; i < 36; ++i)
Common::fill((byte *)&_bob[i], (byte *)&_bob[i] + sizeof(BobItem), 0);
+ for (int i = 0; i < 30; ++i) {
+ Common::fill((byte *)&_lockedAnims[i], (byte *)&_lockedAnims[i] + sizeof(LockAnimItem), 0);
+ }
+
_sortedDisplayCount = 0;
for (int i = 0; i < 51; ++i)
Common::fill((byte *)&_sortedDisplay[i], (byte *)&_sortedDisplay[i] + sizeof(SortItem), 0);
@@ -953,8 +957,8 @@ void ObjectsManager::displayBobAnim() {
byte *dataPtr = _bob[idx]._animData + 20;
int dataIdx = _bob[idx]._animDataIdx;
_bob[idx]._xp = READ_LE_INT16(dataPtr + 2 * dataIdx);
- if (_vm->_globals->_lockedAnims[idx]._enableFl)
- _bob[idx]._xp = _vm->_globals->_lockedAnims[idx]._posX;
+ if (_vm->_objectsManager->_lockedAnims[idx]._enableFl)
+ _bob[idx]._xp = _vm->_objectsManager->_lockedAnims[idx]._posX;
if ( PERSO_ON && idx > 20 )
_bob[idx]._xp += _vm->_eventsManager->_startPos.x;
@@ -986,8 +990,8 @@ void ObjectsManager::displayBobAnim() {
byte *bobData = _bob[idx]._animData + 20;
_bob[idx]._xp = READ_LE_INT16(bobData);
- if (_vm->_globals->_lockedAnims[idx]._enableFl)
- _bob[idx]._xp = _vm->_globals->_lockedAnims[idx]._posX;
+ if (_vm->_objectsManager->_lockedAnims[idx]._enableFl)
+ _bob[idx]._xp = _vm->_objectsManager->_lockedAnims[idx]._posX;
if (PERSO_ON && idx > 20)
_bob[idx]._xp += _vm->_eventsManager->_startPos.x;
@@ -3044,7 +3048,7 @@ void ObjectsManager::loadLinkFile(const Common::String &file) {
Common::File f;
Common::String filename = file + ".LNK";
byte *ptr = _vm->_fileManager->searchCat(filename, RES_LIN);
- size_t nbytes = _vm->_globals->_catalogSize;
+ size_t nbytes = _vm->_fileManager->_catalogSize;
if (ptr == g_PTRNUL) {
if (!f.open(filename))
error("Error opening file - %s", filename.c_str());
@@ -3652,8 +3656,8 @@ void ObjectsManager::handleForest(int screenId, int minX, int maxX, int minY, in
}
void ObjectsManager::lockAnimX(int idx, int x) {
- _vm->_globals->_lockedAnims[idx]._enableFl = true;
- _vm->_globals->_lockedAnims[idx]._posX = x;
+ _vm->_objectsManager->_lockedAnims[idx]._enableFl = true;
+ _vm->_objectsManager->_lockedAnims[idx]._posX = x;
}
/**
diff --git a/engines/hopkins/objects.h b/engines/hopkins/objects.h
index 80dfb3ad7c..f43b09f78b 100644
--- a/engines/hopkins/objects.h
+++ b/engines/hopkins/objects.h
@@ -80,6 +80,11 @@ struct BobItem {
int _zoomOutFactor;
};
+struct LockAnimItem {
+ bool _enableFl;
+ int _posX;
+};
+
class HopkinsEngine;
class ObjectsManager {
@@ -167,6 +172,7 @@ public:
byte *_headSprites;
SpriteItem _sprite[6];
BobItem _bob[36];
+ LockAnimItem _lockedAnims[30];
bool PERSO_ON;
bool BOBTOUS;
diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp
index 1605b0350e..246e611642 100644
--- a/engines/hopkins/sound.cpp
+++ b/engines/hopkins/sound.cpp
@@ -528,8 +528,8 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) {
else if (_vm->_globals->_language == LANG_SP)
filename = "RES_VES.RES";
- catPos = _vm->_globals->_catalogPos;
- catLen = _vm->_globals->_catalogSize;
+ catPos = _vm->_fileManager->_catalogPos;
+ catLen = _vm->_fileManager->_catalogSize;
} else if (!_vm->_fileManager->searchCat(filename + ".APC", RES_VOI)) {
if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS)
filename = "ENG_VOI.RES";
@@ -541,8 +541,8 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) {
else if (_vm->_globals->_language == LANG_SP)
filename = "RES_VES.RES";
- catPos = _vm->_globals->_catalogPos;
- catLen = _vm->_globals->_catalogSize;
+ catPos = _vm->_fileManager->_catalogPos;
+ catLen = _vm->_fileManager->_catalogSize;
} else if (!_vm->_fileManager->searchCat(filename + ".RAW", RES_VOI)) {
if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS)
filename = "ENG_VOI.RES";
@@ -554,8 +554,8 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) {
else if (_vm->_globals->_language == LANG_SP)
filename = "RES_VES.RES";
- catPos = _vm->_globals->_catalogPos;
- catLen = _vm->_globals->_catalogSize;
+ catPos = _vm->_fileManager->_catalogPos;
+ catLen = _vm->_fileManager->_catalogSize;
} else {
if (!f.exists(filename + ".WAV")) {
if (!f.exists(filename + ".APC"))
diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp
index 30148bd401..562d96d75d 100644
--- a/engines/hopkins/talk.cpp
+++ b/engines/hopkins/talk.cpp
@@ -56,7 +56,7 @@ void TalkManager::startAnimatedCharacterDialogue(const Common::String &filename)
bool oldDisableInventFl = _vm->_globals->_disableInventFl;
_vm->_globals->_disableInventFl = true;
_characterBuffer = _vm->_fileManager->searchCat(filename, RES_PER);
- _characterSize = _vm->_globals->_catalogSize;
+ _characterSize = _vm->_fileManager->_catalogSize;
if (_characterBuffer == g_PTRNUL) {
_characterBuffer = _vm->_fileManager->loadFile(filename);
_characterSize = _vm->_fileManager->fileSize(filename);
@@ -156,7 +156,7 @@ void TalkManager::startStaticCharacterDialogue(const Common::String &filename) {
bool oldDisableInventFl = _vm->_globals->_disableInventFl;
_vm->_globals->_disableInventFl = true;
_characterBuffer = _vm->_fileManager->searchCat(filename, RES_PER);
- _characterSize = _vm->_globals->_catalogSize;
+ _characterSize = _vm->_fileManager->_catalogSize;
if (_characterBuffer == g_PTRNUL) {
_characterBuffer = _vm->_fileManager->loadFile(filename);
_characterSize = _vm->_fileManager->fileSize(filename);
@@ -976,7 +976,7 @@ void TalkManager::animateObject(const Common::String &filename) {
_vm->_eventsManager->_mouseCursorId = 4;
_vm->_eventsManager->changeMouseCursor(0);
_characterBuffer = _vm->_fileManager->searchCat(filename, RES_PER);
- _characterSize = _vm->_globals->_catalogSize;
+ _characterSize = _vm->_fileManager->_catalogSize;
if (_characterBuffer == g_PTRNUL) {
_characterBuffer = _vm->_fileManager->loadFile(filename);
_characterSize = _vm->_fileManager->fileSize(filename);