Skip to content

Commit

Permalink
HOPKINS: More refactoring of ObjectsManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Dec 29, 2012
1 parent f7b62d5 commit ea235f7
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 271 deletions.
32 changes: 13 additions & 19 deletions engines/hopkins/anim.cpp
Expand Up @@ -608,7 +608,7 @@ void AnimationManager::clearAnim() {

for (int idx = 0; idx < 8; ++idx) {
_vm->_globals.Bank[idx]._data = _vm->_globals.freeMemory(_vm->_globals.Bank[idx]._data);
_vm->_globals.Bank[idx].field4 = 0;
_vm->_globals.Bank[idx]._loadedFl = false;
_vm->_globals.Bank[idx]._filename = "";
_vm->_globals.Bank[idx]._fileHeader = 0;
_vm->_globals.Bank[idx].field1C = 0;
Expand All @@ -619,41 +619,35 @@ void AnimationManager::clearAnim() {
* Load Sprite Bank
*/
int AnimationManager::loadSpriteBank(int idx, const Common::String &filename) {
byte *v3;
byte *v4;
byte *v13;
byte *ptr;
byte *v19;
int result = 0;
_vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, filename);
_vm->_globals.Bank[idx].field1C = _vm->_fileManager.fileSize(_vm->_globals._curFilename);
_vm->_globals.Bank[idx].field4 = 1;
_vm->_globals.Bank[idx]._loadedFl = true;
_vm->_globals.Bank[idx]._filename = filename;

v3 = _vm->_fileManager.loadFile(_vm->_globals._curFilename);
v4 = v3;
byte *fileDataPtr = _vm->_fileManager.loadFile(_vm->_globals._curFilename);

_vm->_globals.Bank[idx]._fileHeader = 0;
if (*(v3 + 1) == 'L' && *(v3 + 2) == 'E')
if (fileDataPtr[1] == 'L' && fileDataPtr[2] == 'E')
_vm->_globals.Bank[idx]._fileHeader = 1;
if (*(v3 + 1) == 'O' && *(v3 + 2) == 'R')
else if (fileDataPtr[1] == 'O' && fileDataPtr[2] == 'R')
_vm->_globals.Bank[idx]._fileHeader = 2;

if (_vm->_globals.Bank[idx]._fileHeader) {
_vm->_globals.Bank[idx]._data = v3;
_vm->_globals.Bank[idx]._data = fileDataPtr;

bool loopCond = false;
int v8 = 0;
int width;
int height;
do {
ptr = v4;
width = _vm->_objectsManager.getWidth(v4, v8);
height = _vm->_objectsManager.getHeight(ptr, v8);
v4 = ptr;
width = _vm->_objectsManager.getWidth(fileDataPtr, v8);
height = _vm->_objectsManager.getHeight(fileDataPtr, v8);
if (!width && !height)
loopCond = true;
if (!loopCond)
else
++v8;
if (v8 > 249)
loopCond = true;
Expand Down Expand Up @@ -691,13 +685,13 @@ int AnimationManager::loadSpriteBank(int idx, const Common::String &filename) {

result = 0;
} else {
_vm->_globals.freeMemory(ptr);
_vm->_globals.Bank[idx].field4 = 0;
_vm->_globals.freeMemory(fileDataPtr);
_vm->_globals.Bank[idx]._loadedFl = false;
result = -2;
}
} else {
_vm->_globals.freeMemory(v3);
_vm->_globals.Bank[idx].field4 = 0;
_vm->_globals.freeMemory(fileDataPtr);
_vm->_globals.Bank[idx]._loadedFl = false;
result = -1;
}

Expand Down
2 changes: 1 addition & 1 deletion engines/hopkins/globals.cpp
Expand Up @@ -438,7 +438,7 @@ void Globals::INIT_ANIM() {

for (int idx = 0; idx < 8; ++idx) {
Bank[idx]._data = g_PTRNUL;
Bank[idx].field4 = 0;
Bank[idx]._loadedFl = false;
Bank[idx]._filename = "";
Bank[idx]._fileHeader = 0;
Bank[idx].field1C = 0;
Expand Down
4 changes: 2 additions & 2 deletions engines/hopkins/globals.h
Expand Up @@ -66,15 +66,15 @@ struct BqeAnimItem {

struct BankItem {
byte *_data;
int8 field4;
bool _loadedFl;
Common::String _filename;
int _fileHeader;
int field1A;
uint32 field1C;
};

struct ListeItem {
int field0;
bool field0;
int field2;
int field4;
int _width;
Expand Down

0 comments on commit ea235f7

Please sign in to comment.