scummvm/engines/adl/hires2.cpp

200 lines
5.9 KiB
C++
Raw Normal View History

2016-03-10 10:46:06 +01:00
/* 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 "common/system.h"
#include "common/debug.h"
#include "common/error.h"
#include "common/file.h"
#include "common/stream.h"
#include "adl/adl_v2.h"
2018-07-28 14:39:12 +02:00
#include "adl/display_a2.h"
2016-03-13 11:43:48 +01:00
#include "adl/graphics.h"
2016-03-23 11:14:51 +01:00
#include "adl/disk.h"
2016-03-10 10:46:06 +01:00
namespace Adl {
2017-06-26 11:36:45 +02:00
class HiResBaseEngine : public AdlEngine_v2 {
public:
2017-06-26 11:36:45 +02:00
HiResBaseEngine(OSystem *syst, const AdlGameDescription *gd, const byte numRooms, const byte numMsgs, const byte numItemPics);
private:
// AdlEngine
2020-02-09 12:05:27 +01:00
void init() override;
void initGameState() override;
2016-03-10 12:09:59 +01:00
2017-06-26 11:36:45 +02:00
const byte _numRooms, _numMsgs, _numItemPics;
};
2016-08-19 15:45:44 +02:00
2017-06-26 11:36:45 +02:00
HiResBaseEngine::HiResBaseEngine(OSystem *syst, const AdlGameDescription *gd, const byte numRooms, const byte numMsgs, const byte numItemPics) :
AdlEngine_v2(syst, gd),
_numRooms(numRooms),
_numMsgs(numMsgs),
_numItemPics(numItemPics) {
_messageIds.cantGoThere = 110;
_messageIds.dontUnderstand = 112;
_messageIds.itemDoesntMove = 114;
_messageIds.itemNotHere = 115;
_messageIds.thanksForPlaying = 113;
2016-03-10 10:46:06 +01:00
}
2017-06-26 11:36:45 +02:00
void HiResBaseEngine::init() {
2018-07-28 14:39:12 +02:00
_graphics = new GraphicsMan_v2<Display_A2>(*static_cast<Display_A2 *>(_display));
2016-08-19 15:45:44 +02:00
_disk = new DiskImage();
2017-06-26 11:36:45 +02:00
if (!_disk->open(getDiskImageName(0)))
error("Failed to open disk image '%s'", getDiskImageName(0).c_str());
2016-03-11 00:24:31 +01:00
_disk->setSectorLimit(13);
2016-08-19 15:45:44 +02:00
2016-04-09 17:00:49 +02:00
StreamPtr stream(_disk->createReadStream(0x1f, 0x2, 0x00, 4));
2017-06-26 11:36:45 +02:00
loadMessages(*stream, _numMsgs);
2016-03-11 00:24:31 +01:00
2016-03-23 11:14:51 +01:00
// Read parser messages
2016-04-03 12:26:26 +02:00
stream.reset(_disk->createReadStream(0x1a, 0x1));
2016-03-23 11:14:51 +01:00
_strings.verbError = readStringAt(*stream, 0x4f);
_strings.nounError = readStringAt(*stream, 0x8e);
_strings.enterCommand = readStringAt(*stream, 0xbc);
// Read time string
2016-04-03 12:26:26 +02:00
stream.reset(_disk->createReadStream(0x19, 0x7, 0xd7));
2016-03-23 11:14:51 +01:00
_strings_v2.time = readString(*stream, 0xff);
2016-04-03 13:45:31 +02:00
// Read line feeds
stream.reset(_disk->createReadStream(0x19, 0xb, 0xf8, 1));
_strings.lineFeeds = readString(*stream);
2016-03-23 11:14:51 +01:00
// Read opcode strings
2016-04-03 12:26:26 +02:00
stream.reset(_disk->createReadStream(0x1a, 0x6, 0x00, 2));
2016-03-23 11:14:51 +01:00
_strings_v2.saveInsert = readStringAt(*stream, 0x5f);
_strings_v2.saveReplace = readStringAt(*stream, 0xe5);
_strings_v2.restoreInsert = readStringAt(*stream, 0x132);
_strings_v2.restoreReplace = readStringAt(*stream, 0x1c2);
_strings.playAgain = readStringAt(*stream, 0x225);
_strings.pressReturn = readStringAt(*stream, 0x25f);
2016-03-11 00:24:31 +01:00
2016-03-26 17:56:55 +01:00
// Load global picture data
2016-04-03 12:26:26 +02:00
stream.reset(_disk->createReadStream(0x19, 0xa, 0x80, 0));
2016-08-28 13:46:11 +02:00
loadPictures(*stream);
2016-03-26 17:56:55 +01:00
2016-03-16 23:12:31 +01:00
// Load item picture data
2016-04-03 12:26:26 +02:00
stream.reset(_disk->createReadStream(0x1e, 0x9, 0x05));
2017-06-26 11:36:45 +02:00
loadItemPictures(*stream, _numItemPics);
2016-03-16 23:12:31 +01:00
2016-03-16 11:04:34 +01:00
// Load commands from executable
2016-04-03 12:26:26 +02:00
stream.reset(_disk->createReadStream(0x1d, 0x7, 0x00, 4));
2016-03-23 11:14:51 +01:00
readCommands(*stream, _roomCommands);
2016-03-16 11:04:34 +01:00
2017-06-26 11:36:45 +02:00
stream.reset(_disk->createReadStream(0x1f, 0x7, 0x00, 3));
2016-03-23 11:14:51 +01:00
readCommands(*stream, _globalCommands);
2016-03-16 11:04:34 +01:00
2016-03-17 10:46:53 +01:00
// Load dropped item offsets
2016-04-03 12:26:26 +02:00
stream.reset(_disk->createReadStream(0x1b, 0x4, 0x15));
2017-06-26 11:36:45 +02:00
loadDroppedItemOffsets(*stream, 16);
2016-03-17 10:46:53 +01:00
2016-03-23 11:14:51 +01:00
// Load verbs
2016-04-03 12:26:26 +02:00
stream.reset(_disk->createReadStream(0x19, 0x0, 0x00, 3));
loadWords(*stream, _verbs, _priVerbs);
2016-03-10 16:55:40 +01:00
2016-03-23 11:14:51 +01:00
// Load nouns
2016-04-03 12:26:26 +02:00
stream.reset(_disk->createReadStream(0x22, 0x2, 0x00, 7));
loadWords(*stream, _nouns, _priNouns);
2016-03-10 10:46:06 +01:00
}
2017-06-26 11:36:45 +02:00
void HiResBaseEngine::initGameState() {
_state.vars.resize(40);
2016-03-16 11:04:34 +01:00
2016-04-03 12:26:26 +02:00
StreamPtr stream(_disk->createReadStream(0x21, 0x5, 0x0e, 7));
2017-06-26 11:36:45 +02:00
loadRooms(*stream, _numRooms);
2016-03-16 17:23:52 +01:00
2016-04-03 12:26:26 +02:00
stream.reset(_disk->createReadStream(0x21, 0x0, 0x00, 2));
loadItems(*stream);
2016-03-14 15:39:19 +01:00
}
2017-06-26 11:36:45 +02:00
class HiRes2Engine : public HiResBaseEngine {
public:
HiRes2Engine(OSystem *syst, const AdlGameDescription *gd);
private:
// AdlEngine
2020-02-09 12:05:27 +01:00
void runIntro() override;
2017-06-26 11:36:45 +02:00
};
HiRes2Engine::HiRes2Engine(OSystem *syst, const AdlGameDescription *gd) :
HiResBaseEngine(syst, gd, 135, 255, 38) {
_messageIds.cantGoThere = 123;
_messageIds.dontUnderstand = 19;
_messageIds.itemDoesntMove = 242;
_messageIds.itemNotHere = 4;
_messageIds.thanksForPlaying = 239;
}
void HiRes2Engine::runIntro() {
// This only works for the 16-sector re-release. The original
// release is not supported at this time, because we don't have
// access to it.
_disk->setSectorLimit(0);
StreamPtr stream(_disk->createReadStream(0x00, 0xd, 0x17, 1));
2018-07-28 14:39:12 +02:00
_display->setMode(Display::kModeText);
2017-06-26 11:36:45 +02:00
Common::String str = readString(*stream);
if (stream->eos() || stream->err())
error("Error reading disk image");
_display->printString(str);
delay(2000);
_disk->setSectorLimit(13);
}
class HiRes3Engine : public HiResBaseEngine {
public:
HiRes3Engine(OSystem *syst, const AdlGameDescription *gd);
};
HiRes3Engine::HiRes3Engine(OSystem *syst, const AdlGameDescription *gd) :
HiResBaseEngine(syst, gd, 138, 255, 36) {
const byte brokenRooms[] = { 18, 24, 54, 98, 102, 108 };
for (int i = 0; i < ARRAYSIZE(brokenRooms); ++i)
_brokenRooms.push_back(brokenRooms[i]);
}
2016-03-10 10:46:06 +01:00
Engine *HiRes2Engine_create(OSystem *syst, const AdlGameDescription *gd) {
return new HiRes2Engine(syst, gd);
}
2017-06-26 11:36:45 +02:00
Engine *HiRes0Engine_create(OSystem *syst, const AdlGameDescription *gd) {
return new HiResBaseEngine(syst, gd, 43, 142, 2);
}
Engine *HiRes3Engine_create(OSystem *syst, const AdlGameDescription *gd) {
return new HiRes3Engine(syst, gd);
}
2016-03-10 10:46:06 +01:00
} // End of namespace Adl