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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
|
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
/*
* Based on ScottFree interpreter version 1.14 developed by Swansea
* University Computer Society without disassembly of any other game
* drivers, only of game databases as permitted by EEC law (for purposes
* of compatibility).
*
* Licensed under GPLv2
*
* https://github.com/angstsmurf/spatterlight/tree/master/terps/scott
*/
#include "common/str.h"
#include "glk/scott/scott.h"
#include "glk/scott/globals.h"
#include "glk/scott/command_parser.h"
#include "glk/scott/decompress_text.h"
#include "glk/scott/decompress_z80.h"
#include "glk/scott/detection.h"
#include "glk/scott/detection_tables.h"
#include "glk/scott/game_info.h"
#include "glk/scott/hulk.h"
#include "glk/scott/line_drawing.h"
#include "glk/scott/saga_draw.h"
#include "glk/scott/c64_checksums.h"
#include "glk/scott/game_specific.h"
#include "glk/scott/resource.h"
#include "glk/scott/load_game.h"
#include "glk/scott/robin_of_sherwood.h"
#include "glk/scott/gremlins.h"
#include "glk/scott/seas_of_blood.h"
#include "glk/scott/load_ti99_4a.h"
namespace Glk {
namespace Scott {
void loadZXSpectrum(Common::SeekableReadStream *f, Common::String md5) {
_G(_entireFile) = new uint8_t[_G(_fileLength)];
size_t result = f->read(_G(_entireFile), _G(_fileLength));
if (result != _G(_fileLength))
g_scott->fatal("File empty or read error!");
uint8_t *uncompressed = decompressZ80(_G(_entireFile), _G(_fileLength));
if (uncompressed != nullptr) {
delete[] _G(_entireFile);
_G(_entireFile) = uncompressed;
_G(_fileLength) = 0xc000;
}
int offset;
DictionaryType dict_type = getId(&offset);
if (dict_type == NOT_A_GAME)
return;
int index = _G(_md5Index)[md5];
if (tryLoading(_G(_games)[index], offset, 0)) {
_G(_game) = &_G(_games)[index];
}
}
void loadC64(Common::SeekableReadStream* f, Common::String md5) {
_G(_entireFile) = new uint8_t[_G(_fileLength)];
size_t result = f->read(_G(_entireFile), _G(_fileLength));
if (result != _G(_fileLength))
g_scott->fatal("File empty or read error!");
_G(_fallbackGame)._gameID = static_cast<GameIDType>(detectC64(&_G(_entireFile), &_G(_fileLength)));
}
void loadTI994A(Common::SeekableReadStream *f) {
_G(_entireFile) = new uint8_t[_G(_fileLength)];
size_t result = f->read(_G(_entireFile), _G(_fileLength));
if (result != _G(_fileLength))
g_scott->fatal("File empty or read error!");
_G(_fallbackGame)._gameID = detectTI994A(f, &_G(_entireFile), &_G(_fileLength));
}
void loadGameFile(Common::SeekableReadStream *f) {
for (int i = 0; i < NUMBER_OF_DIRECTIONS; i++)
_G(_directions)[i] = _G(_englishDirections)[i];
for (int i = 0; i < NUMBER_OF_SKIPPABLE_WORDS; i++)
_G(_skipList)[i] = _G(_englishSkipList)[i];
for (int i = 0; i < NUMBER_OF_DELIMITERS; i++)
_G(_delimiterList)[i] = _G(_englishDelimiterList)[i];
for (int i = 0; i < NUMBER_OF_EXTRA_NOUNS; i++)
_G(_extraNouns)[i] = _G(_englishExtraNouns)[i];
_G(_fileLength) = f->size();
_G(_game) = &_G(_fallbackGame);
Common::String md5 = g_vm->getGameMD5();
const GlkDetectionEntry *p = SCOTT_GAMES;
while (p->_md5) {
if (md5.equalsC(p->_md5)) {
if (!scumm_stricmp(p->_extra, "")) {
_G(_fallbackGame)._gameID = SCOTTFREE;
break;
} else if (!scumm_stricmp(p->_extra, "ZXSpectrum")) {
loadZXSpectrum(f, md5);
break;
} else if (!scumm_stricmp(p->_extra, "C64")) {
loadC64(f, md5);
break;
} else {
loadTI994A(f);
break;
}
}
++p;
}
if (CURRENT_GAME == SCOTTFREE || CURRENT_GAME == TI994A)
return;
/* Copy ZX Spectrum style system messages as base */
for (int i = 6; i < MAX_SYSMESS && g_sysDictZX[i] != nullptr; i++) {
_G(_sys)[i] = g_sysDictZX[i];
}
switch (CURRENT_GAME) {
case ROBIN_OF_SHERWOOD:
loadExtraSherwoodData();
break;
case ROBIN_OF_SHERWOOD_C64:
loadExtraSherwoodData64();
break;
case SEAS_OF_BLOOD:
loadExtraSeasOfBloodData();
break;
case SEAS_OF_BLOOD_C64:
loadExtraSeasOfBlood64Data();
break;
case CLAYMORGUE:
for (int i = OK; i <= RESUME_A_SAVED_GAME; i++)
_G(_sys)[i] = _G(_systemMessages)[6 - OK + i];
for (int i = PLAY_AGAIN; i <= ON_A_SCALE_THAT_RATES; i++)
_G(_sys)[i] = _G(_systemMessages)[2 - PLAY_AGAIN + i];
break;
case ADVENTURELAND:
for (int i = PLAY_AGAIN; i <= ON_A_SCALE_THAT_RATES; i++)
_G(_sys)[i] = _G(_systemMessages)[2 - PLAY_AGAIN + i];
for (int i = OK; i <= YOU_HAVENT_GOT_IT; i++)
_G(_sys)[i] = _G(_systemMessages)[6 - OK + i];
for (int i = YOU_DONT_SEE_IT; i <= RESUME_A_SAVED_GAME; i++)
_G(_sys)[i] = _G(_systemMessages)[13 - YOU_DONT_SEE_IT + i];
break;
case ADVENTURELAND_C64:
adventureland64Sysmess();
break;
case CLAYMORGUE_C64:
claymorgue64Sysmess();
break;
case GREMLINS_GERMAN_C64:
loadExtraGermanGremlinsc64Data();
break;
case SPIDERMAN_C64:
spiderman64Sysmess();
break;
case SUPERGRAN_C64:
supergran64Sysmess();
break;
case SAVAGE_ISLAND_C64:
_G(_items)[20]._image = 13;
// fallthrough
case SAVAGE_ISLAND2_C64:
_G(_sys)[IM_DEAD] = "I'm DEAD!! ";
if (CURRENT_GAME == SAVAGE_ISLAND2_C64)
_G(_rooms)[30]._image = 20;
break;
case SAVAGE_ISLAND:
_G(_items)[20]._image = 13;
// fallthrough
case SAVAGE_ISLAND2:
MY_LOC = 30; /* Both parts of Savage Island begin in room 30 */
// fallthrough
case GREMLINS_GERMAN:
case GREMLINS:
case SUPERGRAN:
for (int i = DROPPED; i <= OK; i++)
_G(_sys)[i] = _G(_systemMessages)[2 - DROPPED + i];
for (int i = I_DONT_UNDERSTAND; i <= THATS_BEYOND_MY_POWER; i++)
_G(_sys)[i] = _G(_systemMessages)[6 - I_DONT_UNDERSTAND + i];
for (int i = YOU_ARE; i <= HIT_ENTER; i++)
_G(_sys)[i] = _G(_systemMessages)[17 - YOU_ARE + i];
_G(_sys)[PLAY_AGAIN] = _G(_systemMessages)[5];
_G(_sys)[YOURE_CARRYING_TOO_MUCH] = _G(_systemMessages)[24];
_G(_sys)[IM_DEAD] = _G(_systemMessages)[25];
_G(_sys)[YOU_CANT_GO_THAT_WAY] = _G(_systemMessages)[14];
break;
case GREMLINS_SPANISH:
loadExtraSpanishGremlinsData();
break;
case HULK_C64:
case HULK:
for (int i = 0; i < 6; i++) {
_G(_sys)[i] = g_sysDictZX[i];
}
break;
default:
if (!(_G(_game)->_subType & C64)) {
if (_G(_game)->_subType & MYSTERIOUS) {
for (int i = PLAY_AGAIN; i <= YOU_HAVENT_GOT_IT; i++)
_G(_sys)[i] = _G(_systemMessages)[2 - PLAY_AGAIN + i];
for (int i = YOU_DONT_SEE_IT; i <= WHAT_NOW; i++)
_G(_sys)[i] = _G(_systemMessages)[15 - YOU_DONT_SEE_IT + i];
for (int i = LIGHT_HAS_RUN_OUT; i <= RESUME_A_SAVED_GAME; i++)
_G(_sys)[i] = _G(_systemMessages)[31 - LIGHT_HAS_RUN_OUT + i];
_G(_sys)[ITEM_DELIMITER] = " - ";
_G(_sys)[MESSAGE_DELIMITER] = "\n";
_G(_sys)[YOU_SEE] = "\nThings I can see:\n";
break;
} else {
for (int i = PLAY_AGAIN; i <= RESUME_A_SAVED_GAME; i++)
_G(_sys)[i] = _G(_systemMessages)[2 - PLAY_AGAIN + i];
}
}
break;
}
switch (CURRENT_GAME) {
case GREMLINS_GERMAN:
loadExtraGermanGremlinsData();
break;
case GREMLINS_GERMAN_C64:
loadExtraGermanGremlinsc64Data();
break;
default:
break;
}
if ((_G(_game)->_subType & (C64 | MYSTERIOUS)) == (MYSTERIOUS | C64)) {
mysterious64Sysmess();
}
/* If it is a C64 or a Mysterious Adventures game, we have setup the graphics already */
if (!(_G(_game)->_subType & (C64 | MYSTERIOUS)) && _G(_game)->_numberOfPictures > 0) {
sagaSetup(0);
}
}
} // End of namespace Scott
} // End of namespace Glk
|