1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "access/resources.h"
#include "access/access.h"
#include "access/amazon/amazon_resources.h"
#include "access/martian/martian_resources.h"
#include "common/translation.h"
namespace Access {
Resources *Resources::init(AccessEngine *vm) {
if (vm->getGameID() == GType_Amazon)
return new Amazon::AmazonResources(vm);
else if (vm->getGameID() == GType_MartianMemorandum)
return new Martian::MartianResources(vm);
error("Unknown game");
}
bool Resources::load(Common::String &errorMessage) {
Common::File f;
Common::String filename = "access.dat";
if (!f.open(filename.c_str())) {
errorMessage = Common::String::format(_("Unable to locate the '%s' engine data file."), filename.c_str());
return false;
}
// Check for the magic identifier
char buffer[4];
f.read(buffer, 4);
if (strncmp(buffer, "SVMA", 4)) {
errorMessage = Common::String::format(_("The '%s' engine data file is corrupt."), filename.c_str());
return false;
}
// Validate the version number
uint expectedVersion = 1;
uint version = f.readUint16LE();
if (version != expectedVersion) {
errorMessage = Common::String::format(
_("Incorrect version of the '%s' engine data file found. Expected %d.%d but got %d.%d."),
filename.c_str(), expectedVersion, 0, version, 0);
return false;
}
// Load in the index
uint count = f.readUint16LE();
_datIndex.resize(count);
for (uint idx = 0; idx < _datIndex.size(); ++idx) {
_datIndex[idx]._gameId = f.readByte();
_datIndex[idx]._discType = f.readByte();
_datIndex[idx]._demoType = f.readByte();
byte language = f.readByte();
switch (language) {
case 0:
_datIndex[idx]._language = (Common::Language)0;
break;
case 5:
_datIndex[idx]._language = Common::EN_ANY;
break;
default:
error("Unknown language");
break;
}
_datIndex[idx]._fileOffset = f.readUint32LE();
}
// Load in the data for the game
load(f);
return true;
}
void Resources::load(Common::SeekableReadStream &s) {
uint count;
// Get the offset of the data for the game
uint entryOffset = findEntry(_vm->getGameID(), _vm->isCD() ? 1 : 0,
_vm->isDemo() ? 1 : 0, _vm->getLanguage());
s.seek(entryOffset);
// Load filename list
count = s.readUint16LE();
FILENAMES.resize(count);
for (uint idx = 0; idx < count; ++idx)
FILENAMES[idx] = readString(s);
// Load the character data
count = s.readUint16LE();
CHARTBL.resize(count);
for (uint idx = 0; idx < count; ++idx) {
uint count2 = s.readUint16LE();
CHARTBL[idx].resize(count2);
if (count2 > 0)
s.read(&CHARTBL[idx][0], count2);
}
// Load the room data
count = s.readUint16LE();
ROOMTBL.resize(count);
for (uint idx = 0; idx < count; ++idx) {
ROOMTBL[idx]._desc = readString(s);
ROOMTBL[idx]._travelPos.x = s.readSint16LE();
ROOMTBL[idx]._travelPos.y = s.readSint16LE();
uint count2 = s.readUint16LE();
ROOMTBL[idx]._data.resize(count2);
if (count2 > 0)
s.read(&ROOMTBL[idx]._data[0], count2);
}
// Load the deaths list
count = s.readUint16LE();
DEATHS.resize(count);
for (uint idx = 0; idx < count; ++idx) {
DEATHS[idx]._screenId = s.readByte();
DEATHS[idx]._msg = readString(s);
}
// Load in the inventory list
count = s.readUint16LE();
INVENTORY.resize(count);
for (uint idx = 0; idx < count; ++idx) {
INVENTORY[idx]._desc = readString(s);
for (uint idx2 = 0; idx2 < 4; ++idx2)
INVENTORY[idx]._combo[idx2] = s.readSint16LE();
}
}
uint Resources::findEntry(byte gameId, byte discType, byte demoType, Common::Language language) {
for (uint idx = 0; idx < _datIndex.size(); ++idx) {
DATEntry &de = _datIndex[idx];
if (de._gameId == gameId && de._discType == discType &&
de._demoType == demoType && de._language == language)
return de._fileOffset;
}
error("Could not locate appropriate access.dat entry");
}
Common::String Resources::readString(Common::SeekableReadStream &s) {
Common::String result;
char c;
while ((c = s.readByte()) != 0)
result += c;
return result;
}
/*------------------------------------------------------------------------*/
const byte INITIAL_PALETTE[18 * 3] = {
0x00, 0x00, 0x00,
0xff, 0xff, 0xff,
0xf0, 0xf0, 0xf0,
0xe0, 0xe0, 0xe0,
0xd0, 0xd0, 0xd0,
0xc0, 0xc0, 0xc0,
0xb0, 0xb0, 0xb0,
0xa0, 0xa0, 0xa0,
0x90, 0x90, 0x90,
0x80, 0x80, 0x80,
0x70, 0x70, 0x70,
0x60, 0x60, 0x60,
0x50, 0x50, 0x50,
0x40, 0x40, 0x40,
0x30, 0x30, 0x30,
0x20, 0x20, 0x20,
0x10, 0x10, 0x10,
0x00, 0x00, 0x00
};
const char *const GENERAL_MESSAGES[] = {
"LOOKING THERE REVEALS NOTHING OF INTEREST.", // LOOK_MESSAGE
"THAT DOESN'T OPEN.", // OPEN_MESSAGE
"THAT WON'T MOVE.", // MOVE_MESSAGE
"YOU CAN'T TAKE THAT.", // GET_MESSAGE
"THAT DOESN'T SEEM TO WORK.", // USE_MESSAGE
"YOU CAN'T CLIMB THAT.", // GO_MESSAGE
"THERE SEEMS TO BE NO RESPONSE.", // TALK_MESSAGE
"THIS OBJECT REQUIRES NO HINTS", // HELP_MESSAGE
"THIS OBJECT REQUIRES NO HINTS", // HELP_MESSAGE
"THAT DOESN'T SEEM TO WORK." // USE_MESSAGE
};
const int INVCOORDS[][4] = {
{ 23, 68, 15, 49 },
{ 69, 114, 15, 49 },
{ 115, 160, 15, 49 },
{ 161, 206, 15, 49 },
{ 207, 252, 15, 49 },
{ 253, 298, 15, 49 },
{ 23, 68, 50, 84 },
{ 69, 114, 50, 84 },
{ 115, 160, 50, 84 },
{ 161, 206, 50, 84 },
{ 207, 252, 50, 84 },
{ 253, 298, 50, 84 },
{ 23, 68, 85, 119 },
{ 69, 114, 85, 119 },
{ 115, 160, 85, 119 },
{ 161, 206, 85, 119 },
{ 207, 252, 85, 119 },
{ 253, 298, 85, 119 },
{ 23, 68, 120, 154 },
{ 69, 114, 120, 154 },
{ 115, 160, 120, 154 },
{ 161, 206, 120, 154 },
{ 207, 252, 120, 154 },
{ 253, 298, 120, 154 },
{ 237, 298, 177, 193 },
{ 25, 85, 177, 193 }
};
} // End of namespace Access
|