aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2005-04-17 22:59:43 +0000
committerMax Horn2005-04-17 22:59:43 +0000
commitc4e7f403f8b36c4c0437b6fa911f383dfa0770ab (patch)
treeface6ccf1d8b387fa5de70ffaaf03a2dbb7c420b
parentadc21c1ac338489b6ef02cb54ae6642495fdbfc5 (diff)
downloadscummvm-rg350-c4e7f403f8b36c4c0437b6fa911f383dfa0770ab.tar.gz
scummvm-rg350-c4e7f403f8b36c4c0437b6fa911f383dfa0770ab.tar.bz2
scummvm-rg350-c4e7f403f8b36c4c0437b6fa911f383dfa0770ab.zip
Split out some index reading code into a new method readIndexBlock()
svn-id: r17659
-rw-r--r--scumm/intern.h4
-rw-r--r--scumm/resource.cpp257
-rw-r--r--scumm/scumm.cpp14
-rw-r--r--scumm/scumm.h2
4 files changed, 147 insertions, 130 deletions
diff --git a/scumm/intern.h b/scumm/intern.h
index f482116312..53944e7430 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -679,10 +679,13 @@ protected:
Win32ResExtractor *_win32ResExtractor;
MacResExtractor *_macResExtractor;
+ byte *_heV7RoomOffsets;
+
int _heSndSoundFreq, _heSndOffset, _heSndChannel, _heSndSoundId, _heSndFlags, _heSBNGId;
public:
ScummEngine_v70he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]);
+ ~ScummEngine_v70he();
Wiz _wiz;
@@ -693,6 +696,7 @@ protected:
virtual void readRoomsOffsets();
virtual void readGlobalObjects();
+ virtual void readIndexBlock(uint32 blocktype, uint32 itemsize);
virtual void redrawBGAreas();
diff --git a/scumm/resource.cpp b/scumm/resource.cpp
index a9cacdf877..9010fb6549 100644
--- a/scumm/resource.cpp
+++ b/scumm/resource.cpp
@@ -280,8 +280,6 @@ void ScummEngine::askForDisk(const char *filename, int disknum) {
void ScummEngine::readIndexFile() {
uint32 blocktype, itemsize;
int numblock = 0;
- int i;
- bool stop = false;
debugC(DEBUG_GENERAL, "readIndexFile()");
@@ -326,141 +324,152 @@ void ScummEngine::readIndexFile() {
_fileHandle->seek(0, SEEK_SET);
}
- while (!stop) {
+ while (true) {
blocktype = fileReadDword();
+ itemsize = _fileHandle->readUint32BE();
if (_fileHandle->ioFailed())
break;
- itemsize = _fileHandle->readUint32BE();
numblock++;
+ readIndexBlock(blocktype, itemsize);
+ }
- switch (blocktype) {
- case MKID('DCHR'):
- case MKID('DIRF'):
- readResTypeList(rtCharset, MKID('CHAR'), "charset");
- break;
-
- case MKID('DOBJ'):
- debug(9, "found DOBJ block, reading object table");
- readGlobalObjects();
- break;
-
- case MKID('RNAM'):
- // Names of rooms. Maybe we should put them into a table, for use by the debugger?
- if (_heversion >= 80) {
- for (int room; (room = _fileHandle->readUint16LE()); ) {
- char buf[20];
- i = 0;
- for (byte s; (s = _fileHandle->readByte()); ) {
- buf[i++] = s;
- }
- buf[i] = 0;
- debug(5, "Room %d: '%s'", room, buf);
- }
- } else {
- for (int room; (room = _fileHandle->readByte()); ) {
- char buf[10];
- _fileHandle->read(buf, 9);
- buf[9] = 0;
- for (i = 0; i < 9; i++)
- buf[i] ^= 0xFF;
- debug(5, "Room %d: '%s'", room, buf);
- }
- }
- break;
-
- case MKID('DLFL'):
- i = _fileHandle->readUint16LE();
- _fileHandle->seek(-2, SEEK_CUR);
- _heV7RoomOffsets = (byte *)calloc(2 + (i * 4), 1);
- _fileHandle->read(_heV7RoomOffsets, (2 + (i * 4)) );
- break;
-
- case MKID('DIRM'):
- readResTypeList(rtImage, MKID('AWIZ'), "images");
- break;
-
- case MKID('DIRT'):
- readResTypeList(rtTalkie, MKID('TLKE'), "talkie");
- break;
-
- case MKID('SVER'):
- _fileHandle->seek(itemsize - 8, SEEK_CUR);
- warning("SVER index block not yet handled, skipping");
- break;
-
- case MKID('DISK'):
- i = _fileHandle->readUint16LE();
- _heV7DiskOffsets = (byte *)calloc(i, 1);
- _fileHandle->read(_heV7DiskOffsets, i);
- break;
-
- case MKID('INIB'):
- _fileHandle->seek(itemsize - 8, SEEK_CUR);
- debug(2, "INIB index block not yet handled, skipping");
- break;
-
- case MKID('DIRI'):
- readResTypeList(rtRoomImage, MKID('RMIM'), "room image");
- break;
-
- case MKID('ANAM'): // Used by: The Dig, FT
- debug(9, "found ANAM block, reading audio names");
- _numAudioNames = _fileHandle->readUint16LE();
- _audioNames = (char*)malloc(_numAudioNames * 9);
- _fileHandle->read(_audioNames, _numAudioNames * 9);
- break;
-
- case MKID('DIRR'):
- case MKID('DROO'):
- readResTypeList(rtRoom, MKID('ROOM'), "room");
- break;
-
- case MKID('DRSC'):
- readResTypeList(rtRoomScripts, MKID('RMSC'), "room script");
- break;
-
- case MKID('DSCR'):
- case MKID('DIRS'):
- readResTypeList(rtScript, MKID('SCRP'), "script");
- break;
-
- case MKID('DCOS'):
- case MKID('DIRC'):
- readResTypeList(rtCostume, MKID('COST'), "costume");
- break;
-
- case MKID('MAXS'):
- readMAXS(itemsize);
- allocateArrays();
- break;
-
- case MKID('DIRN'):
- case MKID('DSOU'):
- readResTypeList(rtSound, MKID('SOUN'), "sound");
- break;
+// if (numblock!=9)
+// error("Not enough blocks read from directory");
- case MKID('AARY'):
- readArrayFromIndexFile();
- break;
+ closeRoom();
+}
- case MKID('LECF'):
- _fileHandle->seek(itemsize - 8, SEEK_CUR);
- debug(2, "LECF index block not yet handled, skipping");
- break;
+void ScummEngine_v70he::readIndexBlock(uint32 blocktype, uint32 itemsize) {
+ int i;
+ switch (blocktype) {
+ case MKID('DLFL'):
+ i = _fileHandle->readUint16LE();
+ _fileHandle->seek(-2, SEEK_CUR);
+ _heV7RoomOffsets = (byte *)calloc(2 + (i * 4), 1);
+ _fileHandle->read(_heV7RoomOffsets, (2 + (i * 4)) );
+ break;
+
+ case MKID('DISK'):
+ i = _fileHandle->readUint16LE();
+ _heV7DiskOffsets = (byte *)calloc(i, 1);
+ _fileHandle->read(_heV7DiskOffsets, i);
+ break;
- default:
- error("Bad ID %04X('%s') found in index file directory!", blocktype,
- tag2str(blocktype));
- return;
- }
+ default:
+ ScummEngine::readIndexBlock(blocktype, itemsize);
}
+}
-// if (numblock!=9)
-// error("Not enough blocks read from directory");
+void ScummEngine::readIndexBlock(uint32 blocktype, uint32 itemsize) {
+ int i;
+ switch (blocktype) {
+ case MKID('DCHR'):
+ case MKID('DIRF'):
+ readResTypeList(rtCharset, MKID('CHAR'), "charset");
+ break;
+
+ case MKID('DOBJ'):
+ debug(9, "found DOBJ block, reading object table");
+ readGlobalObjects();
+ break;
+
+ case MKID('RNAM'):
+ // Names of rooms. Maybe we should put them into a table, for use by the debugger?
+ if (_heversion >= 80) {
+ for (int room; (room = _fileHandle->readUint16LE()); ) {
+ char buf[20];
+ i = 0;
+ for (byte s; (s = _fileHandle->readByte()); ) {
+ buf[i++] = s;
+ }
+ buf[i] = 0;
+ debug(5, "Room %d: '%s'", room, buf);
+ }
+ } else {
+ for (int room; (room = _fileHandle->readByte()); ) {
+ char buf[10];
+ _fileHandle->read(buf, 9);
+ buf[9] = 0;
+ for (i = 0; i < 9; i++)
+ buf[i] ^= 0xFF;
+ debug(5, "Room %d: '%s'", room, buf);
+ }
+ }
+ break;
+
+ case MKID('DIRM'):
+ readResTypeList(rtImage, MKID('AWIZ'), "images");
+ break;
+
+ case MKID('DIRT'):
+ readResTypeList(rtTalkie, MKID('TLKE'), "talkie");
+ break;
+
+ case MKID('SVER'):
+ _fileHandle->seek(itemsize - 8, SEEK_CUR);
+ warning("SVER index block not yet handled, skipping");
+ break;
+
+ case MKID('INIB'):
+ _fileHandle->seek(itemsize - 8, SEEK_CUR);
+ debug(2, "INIB index block not yet handled, skipping");
+ break;
+
+ case MKID('DIRI'):
+ readResTypeList(rtRoomImage, MKID('RMIM'), "room image");
+ break;
+
+ case MKID('ANAM'): // Used by: The Dig, FT
+ debug(9, "found ANAM block, reading audio names");
+ _numAudioNames = _fileHandle->readUint16LE();
+ _audioNames = (char*)malloc(_numAudioNames * 9);
+ _fileHandle->read(_audioNames, _numAudioNames * 9);
+ break;
+
+ case MKID('DIRR'):
+ case MKID('DROO'):
+ readResTypeList(rtRoom, MKID('ROOM'), "room");
+ break;
+
+ case MKID('DRSC'):
+ readResTypeList(rtRoomScripts, MKID('RMSC'), "room script");
+ break;
+
+ case MKID('DSCR'):
+ case MKID('DIRS'):
+ readResTypeList(rtScript, MKID('SCRP'), "script");
+ break;
+
+ case MKID('DCOS'):
+ case MKID('DIRC'):
+ readResTypeList(rtCostume, MKID('COST'), "costume");
+ break;
+
+ case MKID('MAXS'):
+ readMAXS(itemsize);
+ allocateArrays();
+ break;
+
+ case MKID('DIRN'):
+ case MKID('DSOU'):
+ readResTypeList(rtSound, MKID('SOUN'), "sound");
+ break;
+
+ case MKID('AARY'):
+ readArrayFromIndexFile();
+ break;
+
+ case MKID('LECF'):
+ _fileHandle->seek(itemsize - 8, SEEK_CUR);
+ debug(2, "LECF index block not yet handled, skipping");
+ break;
- closeRoom();
+ default:
+ error("Bad ID %04X('%s') found in index file directory!", blocktype,
+ tag2str(blocktype));
+ }
}
void ScummEngine::readArrayFromIndexFile() {
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index d99595d392..1a54fa1c82 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -768,7 +768,7 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS
_dumpScripts = false;
_debugMode = 0;
_heV7DiskOffsets = NULL;
- _heV7RoomOffsets = NULL;
+ _heV7RoomIntOffsets = NULL;
_objectOwnerTable = NULL;
_objectRoomTable = NULL;
_objectStateTable = NULL;
@@ -1194,10 +1194,6 @@ ScummEngine::~ScummEngine() {
free(_palManipIntermediatePal);
res.freeResources();
- if (_heversion >= 70) {
- free(_heV7RoomIntOffsets);
- free(_heV7RoomOffsets);
- }
free(_objectStateTable);
free(_objectRoomTable);
@@ -1259,6 +1255,8 @@ ScummEngine_v70he::ScummEngine_v70he(GameDetector *detector, OSystem *syst, cons
_win32ResExtractor = new Win32ResExtractor(this);
_macResExtractor = new MacResExtractor(this);
+ _heV7RoomOffsets = NULL;
+
_heSndSoundId = 0;
_heSndOffset = 0;
_heSndChannel = 0;
@@ -1267,6 +1265,12 @@ ScummEngine_v70he::ScummEngine_v70he(GameDetector *detector, OSystem *syst, cons
_heSBNGId = 0;
}
+ScummEngine_v70he::~ScummEngine_v70he() {
+ free(_heV7DiskOffsets);
+ free(_heV7RoomIntOffsets);
+ free(_heV7RoomOffsets);
+}
+
#pragma mark -
#pragma mark --- Initialization ---
#pragma mark -
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 80ee075b0d..35da5caa02 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -682,7 +682,6 @@ protected:
Common::String _targetName; // This is the game the user calls it, so use for saving
byte _resourceMapper[128];
byte *_heV7DiskOffsets;
- byte *_heV7RoomOffsets;
uint32 *_heV7RoomIntOffsets;
const byte *_resourceLastSearchBuf; // FIXME: need to put it to savefile?
uint32 _resourceLastSearchSize; // FIXME: need to put it to savefile?
@@ -725,6 +724,7 @@ protected:
virtual void readMAXS(int blockSize) = 0;
virtual void readGlobalObjects();
virtual void readIndexFile();
+ virtual void readIndexBlock(uint32 block, uint32 itemsize);
virtual void loadCharset(int i);
void nukeCharset(int i);