aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2011-04-05 13:44:50 +0200
committerMax Horn2011-04-05 15:18:09 +0200
commit7ce3719587cf370b0172dc06f85ded25b3c1f263 (patch)
tree91fd1d5d30a1f64da4a0035c381100136e12bcff
parent827561911ac8ca8136ee062908717225947596ea (diff)
downloadscummvm-rg350-7ce3719587cf370b0172dc06f85ded25b3c1f263.tar.gz
scummvm-rg350-7ce3719587cf370b0172dc06f85ded25b3c1f263.tar.bz2
scummvm-rg350-7ce3719587cf370b0172dc06f85ded25b3c1f263.zip
SCUMM: Move _heV7RoomIntOffsets from ScummEngine to ScummEngine_v70he
-rw-r--r--engines/scumm/he/intern_he.h4
-rw-r--r--engines/scumm/he/sprite_he.cpp2
-rw-r--r--engines/scumm/resource.cpp82
-rw-r--r--engines/scumm/resource_v3.cpp4
-rw-r--r--engines/scumm/resource_v4.cpp4
-rw-r--r--engines/scumm/scumm.cpp4
-rw-r--r--engines/scumm/scumm.h6
-rw-r--r--engines/scumm/scumm_v3.h2
-rw-r--r--engines/scumm/scumm_v4.h2
9 files changed, 66 insertions, 44 deletions
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 96807ccbd5..830e940322 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -115,6 +115,7 @@ protected:
byte *_heV7DiskOffsets;
byte *_heV7RoomOffsets;
+ uint32 *_heV7RoomIntOffsets;
int32 _heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq;
@@ -130,6 +131,9 @@ public:
void restoreBackgroundHE(Common::Rect rect, int dirtybit = 0);
protected:
+ virtual void allocateArrays();
+ virtual int readResTypeList(int id);
+ virtual uint32 getResourceRoomOffset(int type, int idx);
virtual void setupOpcodes();
virtual void setupScummVars();
diff --git a/engines/scumm/he/sprite_he.cpp b/engines/scumm/he/sprite_he.cpp
index 5f751d8285..c66eed6ae6 100644
--- a/engines/scumm/he/sprite_he.cpp
+++ b/engines/scumm/he/sprite_he.cpp
@@ -46,7 +46,7 @@ Sprite::~Sprite() {
}
void ScummEngine_v90he::allocateArrays() {
- ScummEngine::allocateArrays();
+ ScummEngine_v70he::allocateArrays();
_sprite->allocTables(_numSprites, MAX(64, _numSprites / 4), 64);
}
diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp
index 5aae59d987..5bc643a5d1 100644
--- a/engines/scumm/resource.cpp
+++ b/engines/scumm/resource.cpp
@@ -167,8 +167,6 @@ void ScummEngine::deleteRoomOffsets() {
/** Read room offsets */
void ScummEngine::readRoomsOffsets() {
- int num, room;
-
debug(9, "readRoomOffsets()");
if (_game.features & GF_SMALL_HEADER) {
@@ -177,13 +175,12 @@ void ScummEngine::readRoomsOffsets() {
_fileHandle->seek(16, SEEK_SET);
}
- num = _fileHandle->readByte();
+ int num = _fileHandle->readByte();
while (num--) {
- room = _fileHandle->readByte();
+ int room = _fileHandle->readByte();
+ int offset = _fileHandle->readUint32LE();
if (_res->roomoffs[rtRoom][room] != RES_INVALID_OFFSET) {
- _res->roomoffs[rtRoom][room] = _fileHandle->readUint32LE();
- } else {
- _fileHandle->readUint32LE();
+ _res->roomoffs[rtRoom][room] = offset;
}
}
}
@@ -491,7 +488,7 @@ void ScummEngine::readArrayFromIndexFile() {
error("readArrayFromIndexFile() not supported in pre-V6 games");
}
-void ScummEngine::readResTypeList(int id) {
+int ScummEngine::readResTypeList(int id) {
int num;
int i;
@@ -511,16 +508,27 @@ void ScummEngine::readResTypeList(int id) {
}
for (i = 0; i < num; i++) {
_res->roomoffs[id][i] = _fileHandle->readUint32LE();
-
- if (id == rtRoom && _game.heversion >= 70)
- _heV7RoomIntOffsets[i] = _res->roomoffs[id][i];
}
- if (_game.heversion >= 70) {
+ return num;
+}
+
+int ScummEngine_v70he::readResTypeList(int id) {
+ int num;
+ int i;
+
+ num = ScummEngine::readResTypeList(id);
+
+ if (id == rtRoom)
for (i = 0; i < num; i++) {
- _res->globsize[id][i] = _fileHandle->readUint32LE();
+ _heV7RoomIntOffsets[i] = _res->roomoffs[rtRoom][i];
}
+
+ for (i = 0; i < num; i++) {
+ _res->globsize[id][i] = _fileHandle->readUint32LE();
}
+
+ return num;
}
void ResourceManager::allocResTypeData(int id, uint32 tag, int num_, const char *name_, int mode_) {
@@ -635,18 +643,9 @@ int ScummEngine::loadResource(int type, int idx) {
if (roomNr == 0)
roomNr = _roomResource;
- if (type == rtRoom) {
- if (_game.version == 8)
- fileOffs = 8;
- else if (_game.heversion >= 70)
- fileOffs = _heV7RoomIntOffsets[idx];
- else
- fileOffs = 0;
- } else {
- fileOffs = _res->roomoffs[type][idx];
- if (fileOffs == RES_INVALID_OFFSET)
- return 0;
- }
+ fileOffs = getResourceRoomOffset(type, idx);
+ if (fileOffs == RES_INVALID_OFFSET)
+ return 0;
openRoom(roomNr);
@@ -691,13 +690,11 @@ int ScummEngine::loadResource(int type, int idx) {
dumpResource("script-", idx, getResourceAddress(rtScript, idx));
}
- if (!_fileHandle->err() && !_fileHandle->eos()) {
- return 1;
+ if (_fileHandle->err() || _fileHandle->eos()) {
+ error("Cannot read resource");
}
- _res->nukeResource(type, idx);
-
- error("Cannot read resource");
+ return 1;
}
int ScummEngine::getResourceRoomNr(int type, int idx) {
@@ -706,6 +703,20 @@ int ScummEngine::getResourceRoomNr(int type, int idx) {
return _res->roomno[type][idx];
}
+uint32 ScummEngine::getResourceRoomOffset(int type, int idx) {
+ if (type == rtRoom) {
+ return (_game.version == 8) ? 8 : 0;
+ }
+ return _res->roomoffs[type][idx];
+}
+
+uint32 ScummEngine_v70he::getResourceRoomOffset(int type, int idx) {
+ if (type == rtRoom) {
+ return _heV7RoomIntOffsets[idx];
+ }
+ return _res->roomoffs[type][idx];
+}
+
int ScummEngine::getResourceSize(int type, int idx) {
byte *ptr = getResourceAddress(type, idx);
assert(ptr);
@@ -1295,13 +1306,16 @@ void ScummEngine::allocateArrays() {
_res->allocResTypeData(rtMatrix, 0, 10, "boxes", 0);
_res->allocResTypeData(rtImage, MKID_BE('AWIZ'), _numImages, "images", 1);
_res->allocResTypeData(rtTalkie, MKID_BE('TLKE'), _numTalkies, "talkie", 1);
+}
- if (_game.heversion >= 70) {
- _res->allocResTypeData(rtSpoolBuffer, 0, 9, "spool buffer", 1);
- _heV7RoomIntOffsets = (uint32 *)calloc(_numRooms, sizeof(uint32));
- }
+void ScummEngine_v70he::allocateArrays() {
+ ScummEngine::allocateArrays();
+
+ _res->allocResTypeData(rtSpoolBuffer, 0, 9, "spool buffer", 1);
+ _heV7RoomIntOffsets = (uint32 *)calloc(_numRooms, sizeof(uint32));
}
+
void ScummEngine::dumpResource(const char *tag, int idx, const byte *ptr, int length) {
char buf[256];
Common::DumpFile out;
diff --git a/engines/scumm/resource_v3.cpp b/engines/scumm/resource_v3.cpp
index 0728395055..5f23720ce9 100644
--- a/engines/scumm/resource_v3.cpp
+++ b/engines/scumm/resource_v3.cpp
@@ -32,7 +32,7 @@ namespace Scumm {
extern const char *resTypeFromId(int id);
-void ScummEngine_v3old::readResTypeList(int id) {
+int ScummEngine_v3old::readResTypeList(int id) {
int num;
int i;
@@ -57,6 +57,8 @@ void ScummEngine_v3old::readResTypeList(int id) {
if (_res->roomoffs[id][i] == 0xFFFF)
_res->roomoffs[id][i] = (uint32)RES_INVALID_OFFSET;
}
+
+ return num;
}
void ScummEngine_v3old::readIndexFile() {
diff --git a/engines/scumm/resource_v4.cpp b/engines/scumm/resource_v4.cpp
index 808fcbd73e..b1d98494d4 100644
--- a/engines/scumm/resource_v4.cpp
+++ b/engines/scumm/resource_v4.cpp
@@ -33,7 +33,7 @@ namespace Scumm {
extern const char *resTypeFromId(int id);
-void ScummEngine_v4::readResTypeList(int id) {
+int ScummEngine_v4::readResTypeList(int id) {
int num;
int i;
@@ -49,6 +49,8 @@ void ScummEngine_v4::readResTypeList(int id) {
_res->roomno[id][i] = _fileHandle->readByte();
_res->roomoffs[id][i] = _fileHandle->readUint32LE();
}
+
+ return num;
}
void ScummEngine_v4::readIndexFile() {
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index bd8b3e5759..7b98c86506 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -201,7 +201,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_bootParam = 0;
_dumpScripts = false;
_debugMode = 0;
- _heV7RoomIntOffsets = NULL;
_objectOwnerTable = NULL;
_objectRoomTable = NULL;
_objectStateTable = NULL;
@@ -789,6 +788,7 @@ ScummEngine_v70he::ScummEngine_v70he(OSystem *syst, const DetectorResult &dr)
_heV7DiskOffsets = NULL;
_heV7RoomOffsets = NULL;
+ _heV7RoomIntOffsets = NULL;
_heSndSoundId = 0;
_heSndOffset = 0;
@@ -805,8 +805,8 @@ ScummEngine_v70he::ScummEngine_v70he(OSystem *syst, const DetectorResult &dr)
ScummEngine_v70he::~ScummEngine_v70he() {
delete _resExtractor;
free(_heV7DiskOffsets);
- free(_heV7RoomIntOffsets);
free(_heV7RoomOffsets);
+ free(_heV7RoomIntOffsets);
free(_storedFlObjects);
}
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 43c86cdc9f..f3af84bb04 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -773,7 +773,6 @@ public:
protected:
int _resourceHeaderSize;
byte _resourceMapper[128];
- uint32 *_heV7RoomIntOffsets;
const byte *_resourceLastSearchBuf; // FIXME: need to put it to savefile?
uint32 _resourceLastSearchSize; // FIXME: need to put it to savefile?
@@ -786,11 +785,13 @@ protected:
bool openResourceFile(const Common::String &filename, byte encByte); // TODO: Use Common::String
void loadPtrToResource(int type, int i, const byte *ptr);
- virtual void readResTypeList(int id);
+ virtual int readResTypeList(int id);
// void allocResTypeData(int id, uint32 tag, int num, const char *name, int mode);
// byte *createResource(int type, int index, uint32 size);
int loadResource(int type, int i);
// void nukeResource(int type, int i);
+ int getResourceRoomNr(int type, int idx);
+ virtual uint32 getResourceRoomOffset(int type, int idx);
int getResourceSize(int type, int idx);
public:
@@ -798,7 +799,6 @@ public:
virtual byte *getStringAddress(int i);
byte *getStringAddressVar(int i);
void ensureResourceLoaded(int type, int i);
- int getResourceRoomNr(int type, int index);
protected:
int readSoundResource(int index);
diff --git a/engines/scumm/scumm_v3.h b/engines/scumm/scumm_v3.h
index abe75cd64d..6e8d593a35 100644
--- a/engines/scumm/scumm_v3.h
+++ b/engines/scumm/scumm_v3.h
@@ -62,7 +62,7 @@ public:
ScummEngine_v3old(OSystem *syst, const DetectorResult &dr);
protected:
- virtual void readResTypeList(int id);
+ virtual int readResTypeList(int id);
virtual void readIndexFile();
virtual void setupRoomSubBlocks();
virtual void resetRoomSubBlocks();
diff --git a/engines/scumm/scumm_v4.h b/engines/scumm/scumm_v4.h
index be3f6cb47e..653cfc228e 100644
--- a/engines/scumm/scumm_v4.h
+++ b/engines/scumm/scumm_v4.h
@@ -59,7 +59,7 @@ protected:
virtual void scummLoop_handleSaveLoad();
- virtual void readResTypeList(int id);
+ virtual int readResTypeList(int id);
virtual void readIndexFile();
virtual void loadCharset(int no);
virtual void resetRoomObjects();