aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2005-04-04 00:12:41 +0000
committerMax Horn2005-04-04 00:12:41 +0000
commit5b53b4a4637f81924659aaafc499b1b46269dfce (patch)
tree716e29531f9fa00eabfe98997cf5a6d02d897f56 /scumm
parent789cad236c66cc0fc86b43c49a21894b5f1e5592 (diff)
downloadscummvm-rg350-5b53b4a4637f81924659aaafc499b1b46269dfce.tar.gz
scummvm-rg350-5b53b4a4637f81924659aaafc499b1b46269dfce.tar.bz2
scummvm-rg350-5b53b4a4637f81924659aaafc499b1b46269dfce.zip
Cleaning up the charset loading code some more
svn-id: r17367
Diffstat (limited to 'scumm')
-rw-r--r--scumm/resource.cpp59
-rw-r--r--scumm/resource_v3.cpp12
-rw-r--r--scumm/resource_v4.cpp14
-rw-r--r--scumm/scumm.h2
4 files changed, 38 insertions, 49 deletions
diff --git a/scumm/resource.cpp b/scumm/resource.cpp
index 80390d50e1..82adc89f91 100644
--- a/scumm/resource.cpp
+++ b/scumm/resource.cpp
@@ -42,7 +42,7 @@ static const byte *findResourceSmall(uint32 tag, const byte *searchin);
/* Open a room */
void ScummEngine::openRoom(int room) {
- int room_offs, roomlimit;
+ int room_offs;
bool result;
char buf[128];
char buf2[128] = "";
@@ -65,14 +65,7 @@ void ScummEngine::openRoom(int room) {
/* Either xxx.lfl or monkey.xxx file name */
while (1) {
- if (_features & GF_SMALL_NAMES)
- roomlimit = 98;
- else
- roomlimit = 900;
- if (_features & GF_EXTERNAL_CHARSET && room >= roomlimit)
- room_offs = 0;
- else
- room_offs = room ? res.roomoffs[rtRoom][room] : 0;
+ room_offs = room ? res.roomoffs[rtRoom][room] : 0;
if (room_offs == -1)
break;
@@ -81,7 +74,26 @@ void ScummEngine::openRoom(int room) {
_fileOffset = res.roomoffs[rtRoom][room];
return;
}
- if (!(_features & GF_SMALL_HEADER)) {
+ if (_version <= 3) {
+ sprintf(buf, "%.2d.lfl", room);
+ // Maniac Mansion demo has .man instead of .lfl
+ if (_gameId == GID_MANIAC)
+ sprintf(buf2, "%.2d.man", room);
+ encByte = (_features & GF_USE_KEY) ? 0xFF : 0;
+ } else if (_features & GF_SMALL_HEADER) {
+ if (room == 0 || room >= 900) {
+ sprintf(buf, "%.3d.lfl", room);
+ encByte = 0;
+ if (openResourceFile(buf, encByte)) {
+ return;
+ }
+ askForDisk(buf, room == 0 ? 0 : res.roomno[rtRoom][room]);
+
+ } else {
+ sprintf(buf, "disk%.2d.lec", room == 0 ? 0 : res.roomno[rtRoom][room]);
+ encByte = 0x69;
+ }
+ } else {
if (_heversion >= 70) { // Windows titles
if (_heversion >= 98) {
@@ -107,34 +119,15 @@ void ScummEngine::openRoom(int room) {
sprintf(buf, "%s.la%d", _gameName.c_str(), room == 0 ? 0 : res.roomno[rtRoom][room]);
sprintf(buf2, "%s.%.3d", _gameName.c_str(), room == 0 ? 0 : res.roomno[rtRoom][room]);
- } else if (_features & GF_HUMONGOUS)
+ } else if (_features & GF_HUMONGOUS) {
sprintf(buf, "%s.he%.1d", _gameName.c_str(), room == 0 ? 0 : res.roomno[rtRoom][room]);
- else {
+ } else {
sprintf(buf, "%s.%.3d", _gameName.c_str(), room == 0 ? 0 : res.roomno[rtRoom][room]);
if (_gameId == GID_SAMNMAX)
sprintf(buf2, "%s.sm%.1d", _gameName.c_str(), room == 0 ? 0 : res.roomno[rtRoom][room]);
}
encByte = (_features & GF_USE_KEY) ? 0x69 : 0;
- } else if (!(_features & GF_SMALL_NAMES)) {
- if (room == 0 || room >= 900) {
- sprintf(buf, "%.3d.lfl", room);
- encByte = 0;
- if (openResourceFile(buf, encByte)) {
- return;
- }
- askForDisk(buf, room == 0 ? 0 : res.roomno[rtRoom][room]);
-
- } else {
- sprintf(buf, "disk%.2d.lec", room == 0 ? 0 : res.roomno[rtRoom][room]);
- encByte = 0x69;
- }
- } else {
- sprintf(buf, "%.2d.lfl", room);
- // Maniac Mansion demo has .man instead of .lfl
- if (_gameId == GID_MANIAC)
- sprintf(buf2, "%.2d.man", room);
- encByte = (_features & GF_USE_KEY) ? 0xFF : 0;
}
// If we have substitute
@@ -158,8 +151,6 @@ void ScummEngine::openRoom(int room) {
if (result) {
if (room == 0)
return;
- if (_features & GF_EXTERNAL_CHARSET && room >= roomlimit)
- return;
deleteRoomOffsets();
readRoomsOffsets();
_fileOffset = res.roomoffs[rtRoom][room];
@@ -633,7 +624,7 @@ int ScummEngine::loadResource(int type, int idx) {
_fileHandle->seek(-2, SEEK_CUR);
}
} else if (_features & GF_SMALL_HEADER) {
- if (!(_features & GF_SMALL_NAMES))
+ if (_version == 4)
_fileHandle->seek(8, SEEK_CUR);
size = _fileHandle->readUint32LE();
tag = _fileHandle->readUint16LE();
diff --git a/scumm/resource_v3.cpp b/scumm/resource_v3.cpp
index 7c6855197a..4ea5a5b7b0 100644
--- a/scumm/resource_v3.cpp
+++ b/scumm/resource_v3.cpp
@@ -104,27 +104,21 @@ void ScummEngine_v3::loadCharset(int no) {
uint32 size;
memset(_charsetData, 0, sizeof(_charsetData));
- if (_gameId == GID_ZAK256)
- checkRange(2, 0, no, "Loading illegal charset %d");
- else
- checkRange(4, 0, no, "Loading illegal charset %d");
+ checkRange(2, 0, no, "Loading illegal charset %d");
closeRoom();
File file;
char buf[20];
sprintf(buf, "%02d.LFL", 99 - no);
-
file.open(buf);
-
+
if (file.isOpen() == false) {
error("loadCharset(%d): Missing file charset: %s", no, buf);
}
-
+
size = file.readUint16LE();
file.read(createResource(rtCharset, no, size), size);
-
- file.close();
}
} // End of namespace Scumm
diff --git a/scumm/resource_v4.cpp b/scumm/resource_v4.cpp
index a1a6f5322f..6392f3bf50 100644
--- a/scumm/resource_v4.cpp
+++ b/scumm/resource_v4.cpp
@@ -130,12 +130,18 @@ void ScummEngine_v4::loadCharset(int no) {
checkRange(4, 0, no, "Loading illegal charset %d");
closeRoom();
- openRoom(900 + no);
+ File file;
+ char buf[20];
- size = _fileHandle->readUint32LE() + 11;
+ sprintf(buf, "%03d.LFL", 900 + no);
+ file.open(buf);
- _fileHandle->read(createResource(rtCharset, no, size), size);
- closeRoom();
+ if (file.isOpen() == false) {
+ error("loadCharset(%d): Missing file charset: %s", no, buf);
+ }
+
+ size = file.readUint32LE() + 11;
+ file.read(createResource(rtCharset, no, size), size);
}
void ScummEngine_v4::readMAXS(int blockSize) {
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 0f2a5497b1..6228807699 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -132,8 +132,6 @@ enum GameFeatures {
GF_PC = 1 << 22,
GF_WINDOWS = 1 << 23,
GF_DEMO = 1 << 24,
-
- GF_EXTERNAL_CHARSET = GF_SMALL_HEADER
};
/* SCUMM Debug Channels */