2014-07-29 21:02:28 -04: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.
|
|
|
|
*
|
2021-12-26 18:47:58 +01:00
|
|
|
* 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.
|
2014-12-17 18:25:24 +01:00
|
|
|
*
|
2014-07-29 21:02:28 -04:00
|
|
|
* 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.
|
2014-12-17 18:25:24 +01:00
|
|
|
*
|
2014-07-29 21:02:28 -04:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 18:47:58 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-07-29 21:02:28 -04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "common/debug-channels.h"
|
|
|
|
#include "common/events.h"
|
|
|
|
#include "engines/util.h"
|
2014-08-30 08:45:42 -04:00
|
|
|
#include "graphics/scaler.h"
|
|
|
|
#include "graphics/thumbnail.h"
|
2014-07-29 21:02:28 -04:00
|
|
|
#include "access/access.h"
|
2020-02-08 20:34:15 -08:00
|
|
|
#include "access/debugger.h"
|
2014-07-29 21:02:28 -04:00
|
|
|
|
|
|
|
namespace Access {
|
|
|
|
|
2014-12-17 19:13:23 +01:00
|
|
|
AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
|
|
|
|
: _gameDescription(gameDesc), Engine(syst), _randomSource("Access"),
|
|
|
|
_useItem(_flags[99]), _startup(_flags[170]), _manScaleOff(_flags[172]) {
|
2016-07-28 11:32:54 +03:00
|
|
|
// Set up debug channels
|
|
|
|
|
2015-11-27 12:12:32 -05:00
|
|
|
_aboutBox = nullptr;
|
2014-08-09 15:54:35 -04:00
|
|
|
_animation = nullptr;
|
2014-08-17 11:14:30 -04:00
|
|
|
_bubbleBox = nullptr;
|
2014-08-23 12:09:27 -04:00
|
|
|
_char = nullptr;
|
2014-07-29 22:49:45 -04:00
|
|
|
_events = nullptr;
|
2014-08-02 15:14:42 -04:00
|
|
|
_files = nullptr;
|
2015-11-27 12:12:32 -05:00
|
|
|
_invBox = nullptr;
|
2014-08-09 17:57:34 -04:00
|
|
|
_inventory = nullptr;
|
2015-11-27 12:12:32 -05:00
|
|
|
_helpBox = nullptr;
|
2014-12-19 23:36:53 -05:00
|
|
|
_midi = nullptr;
|
2014-08-05 22:17:30 -04:00
|
|
|
_player = nullptr;
|
2015-11-27 12:12:32 -05:00
|
|
|
_res = nullptr;
|
2014-08-05 22:17:30 -04:00
|
|
|
_room = nullptr;
|
2014-08-02 10:07:54 -04:00
|
|
|
_screen = nullptr;
|
2014-08-05 23:23:49 -04:00
|
|
|
_scripts = nullptr;
|
2014-08-02 15:14:42 -04:00
|
|
|
_sound = nullptr;
|
2015-11-27 12:12:32 -05:00
|
|
|
_travelBox = nullptr;
|
2014-08-23 14:13:26 -04:00
|
|
|
_video = nullptr;
|
2014-08-04 09:21:39 -04:00
|
|
|
|
|
|
|
_destIn = nullptr;
|
2014-08-10 17:49:44 +02:00
|
|
|
_current = nullptr;
|
2014-08-05 20:59:44 -04:00
|
|
|
_mouseMode = 0;
|
2014-12-29 07:22:51 +01:00
|
|
|
_playerDataCount = 0;
|
2014-08-04 22:38:50 -04:00
|
|
|
_currentMan = 0;
|
|
|
|
_currentManOld = -1;
|
|
|
|
_converseMode = 0;
|
2014-08-05 22:17:30 -04:00
|
|
|
_numAnimTimers = 0;
|
|
|
|
_startup = 0;
|
2014-08-05 23:23:49 -04:00
|
|
|
_currentCharFlag = false;
|
|
|
|
_boxSelect = false;
|
2014-08-07 09:23:31 -04:00
|
|
|
_scale = 0;
|
2014-08-06 22:43:40 -04:00
|
|
|
_scaleH1 = _scaleH2 = 0;
|
|
|
|
_scaleN1 = 0;
|
|
|
|
_scaleT1 = 0;
|
|
|
|
_scaleMaxY = 0;
|
|
|
|
_scaleI = 0;
|
2014-12-18 21:45:55 -05:00
|
|
|
_scrollCol = _scrollRow = 0;
|
|
|
|
_scrollX = _scrollY = 0;
|
2014-11-22 22:17:39 -05:00
|
|
|
_imgUnscaled = false;
|
2014-08-30 09:57:51 -04:00
|
|
|
_canSaveLoad = false;
|
2014-12-01 07:59:42 +01:00
|
|
|
_establish = nullptr;
|
2014-08-04 22:38:50 -04:00
|
|
|
|
2014-08-05 20:04:41 -04:00
|
|
|
_conversation = 0;
|
|
|
|
_newTime = 0;
|
|
|
|
_newDate = 0;
|
2014-08-10 16:55:06 -04:00
|
|
|
Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr);
|
2014-08-23 13:13:56 -04:00
|
|
|
Common::fill(&_establishTable[0], &_establishTable[100], false);
|
2014-08-09 18:28:33 -04:00
|
|
|
Common::fill(&_flags[0], &_flags[256], 0);
|
2014-08-06 22:43:40 -04:00
|
|
|
_establishFlag = false;
|
|
|
|
_establishMode = 0;
|
|
|
|
_establishGroup = 0;
|
2014-08-23 23:49:08 +02:00
|
|
|
_establishCtrlTblOfs = 0;
|
2014-08-20 01:46:46 +02:00
|
|
|
_lastTime = g_system->getMillis();
|
|
|
|
_curTime = 0;
|
2014-08-23 23:49:08 +02:00
|
|
|
_narateFile = 0;
|
|
|
|
_txtPages = 0;
|
|
|
|
_sndSubFile = 0;
|
2014-08-30 10:57:45 -04:00
|
|
|
_loadSaveSlot = -1;
|
2014-11-23 22:21:48 +01:00
|
|
|
_vidX = _vidY = 0;
|
2014-12-07 19:53:19 +01:00
|
|
|
_cheatFl = false;
|
2014-12-10 23:25:18 +01:00
|
|
|
_restartFl = false;
|
2014-12-19 23:36:53 -05:00
|
|
|
_printEnd = 0;
|
2015-01-27 07:02:46 +01:00
|
|
|
for (int i = 0; i < 100; i++)
|
|
|
|
_objectsTable[i] = nullptr;
|
|
|
|
_clearSummaryFlag = false;
|
2015-01-05 18:15:12 +01:00
|
|
|
|
2015-01-06 00:40:13 +01:00
|
|
|
for (int i = 0; i < 60; i++)
|
2015-07-24 23:03:22 +03:00
|
|
|
_travel[i] = 0;
|
|
|
|
_startTravelItem = _startTravelBox = 0;
|
2015-01-15 00:40:43 +01:00
|
|
|
for (int i = 0; i < 33; i++)
|
2015-08-03 10:44:36 +02:00
|
|
|
_ask[i] = 0;
|
2015-01-12 00:04:38 +01:00
|
|
|
_startAboutItem = _startAboutBox = 0;
|
2015-01-12 00:23:28 +01:00
|
|
|
_byte26CB5 = 0;
|
2015-07-24 23:03:22 +03:00
|
|
|
_bcnt = 0;
|
|
|
|
_boxDataStart = 0;
|
|
|
|
_boxDataEnd = false;
|
|
|
|
_boxSelectY = 0;
|
|
|
|
_boxSelectYOld = -1;
|
|
|
|
_numLines = 0;
|
|
|
|
_tempList = nullptr;
|
2015-02-04 22:22:50 +01:00
|
|
|
_pictureTaken = 0;
|
2015-01-13 00:46:45 +01:00
|
|
|
|
2015-01-05 22:43:21 +01:00
|
|
|
_vidEnd = false;
|
2023-05-01 09:38:33 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < 6; ++i)
|
|
|
|
_countTbl[i] = 0;
|
2014-07-29 21:02:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
AccessEngine::~AccessEngine() {
|
2014-08-09 15:54:35 -04:00
|
|
|
delete _animation;
|
2014-08-17 11:14:30 -04:00
|
|
|
delete _bubbleBox;
|
2015-01-09 08:20:59 +01:00
|
|
|
delete _helpBox;
|
|
|
|
delete _travelBox;
|
|
|
|
delete _invBox;
|
|
|
|
delete _aboutBox;
|
2014-08-23 12:09:27 -04:00
|
|
|
delete _char;
|
2014-07-29 22:49:45 -04:00
|
|
|
delete _events;
|
2014-08-02 15:14:42 -04:00
|
|
|
delete _files;
|
2014-08-09 17:57:34 -04:00
|
|
|
delete _inventory;
|
2014-12-01 07:49:26 +01:00
|
|
|
delete _midi;
|
2014-08-05 22:17:30 -04:00
|
|
|
delete _player;
|
2015-11-27 12:12:32 -05:00
|
|
|
delete _res;
|
2014-08-05 22:17:30 -04:00
|
|
|
delete _room;
|
2014-08-02 10:07:54 -04:00
|
|
|
delete _screen;
|
2014-08-05 23:23:49 -04:00
|
|
|
delete _scripts;
|
2014-08-02 15:14:42 -04:00
|
|
|
delete _sound;
|
2014-08-23 14:13:26 -04:00
|
|
|
delete _video;
|
2014-08-04 09:21:39 -04:00
|
|
|
|
2014-08-06 08:28:20 -04:00
|
|
|
freeCells();
|
2014-12-01 07:59:42 +01:00
|
|
|
delete _establish;
|
2014-08-04 09:21:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void AccessEngine::setVGA() {
|
2017-10-01 00:56:01 -05:00
|
|
|
initGraphics(320, 200);
|
2014-07-29 21:02:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void AccessEngine::initialize() {
|
2014-08-09 12:12:39 -04:00
|
|
|
if (isCD()) {
|
|
|
|
const Common::FSNode gameDataDir(ConfMan.get("path"));
|
2014-08-28 01:59:53 +02:00
|
|
|
// The CD version contains two versions of the game.
|
|
|
|
// - The MCGA version, in the CDROM folder
|
|
|
|
// - The VESA version, in the TDROM folder
|
|
|
|
// We use the hires version.
|
|
|
|
const Common::FSNode cdromDir = gameDataDir.getChild("tdrom");
|
2014-08-09 12:12:39 -04:00
|
|
|
|
|
|
|
for (int idx = 0; idx < 15; ++idx) {
|
|
|
|
Common::String folder = (idx == 0) ? "game" :
|
|
|
|
Common::String::format("chap%.2d", idx);
|
|
|
|
SearchMan.addSubDirectoryMatching(cdromDir, folder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create sub-objects of the engine
|
2014-08-09 15:54:35 -04:00
|
|
|
_animation = new AnimationManager(this);
|
2015-01-15 00:40:43 +01:00
|
|
|
_bubbleBox = new BubbleBox(this, TYPE_2, 64, 32, 130, 122, 0, 0, 0, 0, "");
|
2015-01-09 08:20:59 +01:00
|
|
|
if (getGameID() == GType_MartianMemorandum) {
|
2015-01-15 00:40:43 +01:00
|
|
|
_helpBox = new BubbleBox(this, TYPE_1, 64, 24, 146, 122, 1, 32, 2, 76, "HELP");
|
|
|
|
_travelBox = new BubbleBox(this, TYPE_1, 64, 32, 194, 122, 1, 24, 2, 74, "TRAVEL");
|
|
|
|
_invBox = new BubbleBox(this, TYPE_1, 64, 32, 146, 122, 1, 32, 2, 76, "INVENTORY");
|
|
|
|
_aboutBox = new BubbleBox(this, TYPE_1, 64, 32, 194, 122, 1, 32, 2, 76, "ASK ABOUT");
|
2015-01-09 08:20:59 +01:00
|
|
|
} else {
|
|
|
|
_helpBox = nullptr;
|
|
|
|
_travelBox = nullptr;
|
|
|
|
_invBox = nullptr;
|
|
|
|
_aboutBox = nullptr;
|
|
|
|
}
|
2014-08-23 12:09:27 -04:00
|
|
|
_char = new CharManager(this);
|
2014-07-29 22:49:45 -04:00
|
|
|
_events = new EventsManager(this);
|
2014-08-02 15:14:42 -04:00
|
|
|
_files = new FileManager(this);
|
2014-08-09 17:57:34 -04:00
|
|
|
_inventory = new InventoryManager(this);
|
2014-11-25 07:47:19 -05:00
|
|
|
_player = Player::init(this);
|
2014-08-02 10:07:54 -04:00
|
|
|
_screen = new Screen(this);
|
2014-08-04 09:21:39 -04:00
|
|
|
_sound = new SoundManager(this, _mixer);
|
2014-12-12 22:33:46 +01:00
|
|
|
_midi = new MusicManager(this);
|
2014-08-23 14:13:26 -04:00
|
|
|
_video = new VideoPlayer(this);
|
2014-08-04 09:21:39 -04:00
|
|
|
|
2020-02-08 20:34:15 -08:00
|
|
|
setDebugger(Debugger::init(this));
|
2014-08-18 20:15:43 -04:00
|
|
|
_buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight());
|
|
|
|
_buffer2.create(g_system->getWidth(), g_system->getHeight());
|
2014-11-23 22:21:48 +01:00
|
|
|
_vidBuf.create(160, 101);
|
2014-08-30 10:57:45 -04:00
|
|
|
|
|
|
|
// If requested, load a savegame instead of showing the intro
|
|
|
|
if (ConfMan.hasKey("save_slot")) {
|
|
|
|
int saveSlot = ConfMan.getInt("save_slot");
|
|
|
|
if (saveSlot >= 0 && saveSlot <= 999)
|
|
|
|
_loadSaveSlot = saveSlot;
|
|
|
|
}
|
2014-07-29 21:02:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error AccessEngine::run() {
|
2015-11-27 12:12:32 -05:00
|
|
|
_res = Resources::init(this);
|
2020-06-20 23:34:23 +05:30
|
|
|
Common::U32String errorMessage;
|
2015-11-27 12:12:32 -05:00
|
|
|
if (!_res->load(errorMessage)) {
|
|
|
|
GUIErrorMessage(errorMessage);
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
2014-08-04 09:21:39 -04:00
|
|
|
setVGA();
|
2014-07-29 21:02:28 -04:00
|
|
|
initialize();
|
|
|
|
|
2014-08-04 21:35:49 -04:00
|
|
|
playGame();
|
2014-08-01 21:32:05 -04:00
|
|
|
|
2014-07-29 21:02:28 -04:00
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
|
|
|
int AccessEngine::getRandomNumber(int maxNumber) {
|
|
|
|
return _randomSource.getRandomNumber(maxNumber);
|
|
|
|
}
|
|
|
|
|
2014-08-23 12:09:27 -04:00
|
|
|
void AccessEngine::loadCells(Common::Array<CellIdent> &cells) {
|
2014-08-06 22:43:40 -04:00
|
|
|
for (uint i = 0; i < cells.size(); ++i) {
|
2014-08-27 22:13:43 -04:00
|
|
|
Resource *spriteData = _files->loadFile(cells[i]);
|
|
|
|
_objectsTable[cells[i]._cell] = new SpriteResource(this, spriteData);
|
|
|
|
delete spriteData;
|
2014-08-06 22:43:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-06 08:28:20 -04:00
|
|
|
void AccessEngine::freeCells() {
|
|
|
|
for (int i = 0; i < 100; ++i) {
|
2014-08-13 22:45:15 -04:00
|
|
|
delete _objectsTable[i];
|
2014-08-06 08:28:20 -04:00
|
|
|
_objectsTable[i] = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-26 21:21:03 -04:00
|
|
|
void AccessEngine::speakText(BaseSurface *s, const Common::String &msg) {
|
2014-10-31 19:44:45 -04:00
|
|
|
Common::String lines = msg;
|
|
|
|
Common::String line;
|
2014-08-24 18:49:34 +02:00
|
|
|
int curPage = 0;
|
|
|
|
int soundsLeft = 0;
|
|
|
|
|
2014-12-06 16:43:30 -05:00
|
|
|
while (!shouldQuit()) {
|
2014-08-24 18:49:34 +02:00
|
|
|
soundsLeft = _countTbl[curPage];
|
|
|
|
_events->zeroKeys();
|
|
|
|
|
|
|
|
int width = 0;
|
2018-07-20 19:05:56 -07:00
|
|
|
bool lastLine = _fonts._font2->getLine(lines, s->_maxChars * 6, line, width);
|
2014-10-31 19:44:45 -04:00
|
|
|
|
2014-08-24 18:49:34 +02:00
|
|
|
// Set font colors
|
2018-07-20 19:05:56 -07:00
|
|
|
Font::_fontColors[0] = 0;
|
|
|
|
Font::_fontColors[1] = 28;
|
|
|
|
Font::_fontColors[2] = 29;
|
|
|
|
Font::_fontColors[3] = 30;
|
2014-08-24 18:49:34 +02:00
|
|
|
|
2018-07-20 19:05:56 -07:00
|
|
|
_fonts._font2->drawString(s, line, s->_printOrg);
|
2014-08-25 23:44:55 +02:00
|
|
|
s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9);
|
2014-08-24 18:49:34 +02:00
|
|
|
|
2014-08-25 23:44:55 +02:00
|
|
|
if ((s->_printOrg.y > _printEnd) && (!lastLine)) {
|
2014-12-12 01:07:47 +01:00
|
|
|
_events->clearEvents();
|
|
|
|
while (!shouldQuit()) {
|
|
|
|
_sound->freeSounds();
|
2014-12-27 17:21:04 +01:00
|
|
|
_sound->loadSoundTable(0, _narateFile + 99, _sndSubFile);
|
2014-12-12 01:07:47 +01:00
|
|
|
_sound->playSound(0);
|
|
|
|
|
2014-12-27 16:05:23 +01:00
|
|
|
while(_sound->isSFXPlaying() && !shouldQuit())
|
|
|
|
_events->pollEvents();
|
2014-12-12 01:07:47 +01:00
|
|
|
|
2014-12-27 17:21:04 +01:00
|
|
|
_scripts->cmdFreeSound();
|
2014-12-12 01:07:47 +01:00
|
|
|
|
|
|
|
if (_events->isKeyMousePressed()) {
|
|
|
|
_sndSubFile += soundsLeft;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
++_sndSubFile;
|
|
|
|
--soundsLeft;
|
|
|
|
if (soundsLeft == 0)
|
2014-10-19 22:03:20 -04:00
|
|
|
break;
|
2014-12-12 01:07:47 +01:00
|
|
|
_events->clearEvents();
|
2014-08-24 18:49:34 +02:00
|
|
|
}
|
|
|
|
}
|
2014-10-19 22:03:20 -04:00
|
|
|
|
|
|
|
s->copyBuffer(&_buffer2);
|
2014-08-25 23:44:55 +02:00
|
|
|
s->_printOrg.y = s->_printStart.y;
|
2014-08-24 18:49:34 +02:00
|
|
|
++curPage;
|
|
|
|
soundsLeft = _countTbl[curPage];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastLine)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-12-17 07:47:55 +01:00
|
|
|
while (soundsLeft) {
|
2014-11-07 22:09:09 -05:00
|
|
|
_sound->freeSounds();
|
|
|
|
Resource *res = _sound->loadSound(_narateFile + 99, _sndSubFile);
|
|
|
|
_sound->_soundTable.push_back(SoundEntry(res, 1));
|
2014-08-30 21:22:11 -04:00
|
|
|
_sound->playSound(0);
|
2014-08-24 18:49:34 +02:00
|
|
|
|
2014-12-27 16:05:23 +01:00
|
|
|
while(_sound->isSFXPlaying() && !shouldQuit())
|
|
|
|
_events->pollEvents();
|
2014-08-24 18:49:34 +02:00
|
|
|
|
2014-12-27 17:21:04 +01:00
|
|
|
_scripts->cmdFreeSound();
|
2014-08-24 18:49:34 +02:00
|
|
|
|
|
|
|
if (_events->_leftButton) {
|
|
|
|
_events->debounceLeft();
|
|
|
|
_sndSubFile += soundsLeft;
|
|
|
|
break;
|
2014-12-06 15:01:52 -05:00
|
|
|
} else if (_events->isKeyPending()) {
|
2014-08-24 18:49:34 +02:00
|
|
|
_sndSubFile += soundsLeft;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
++_sndSubFile;
|
|
|
|
--soundsLeft;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-26 21:21:03 -04:00
|
|
|
void AccessEngine::printText(BaseSurface *s, const Common::String &msg) {
|
2014-10-31 19:44:45 -04:00
|
|
|
Common::String lines = msg;
|
2014-08-31 02:18:02 +02:00
|
|
|
Common::String line;
|
|
|
|
int width = 0;
|
2014-10-31 19:44:45 -04:00
|
|
|
|
|
|
|
for (;;) {
|
2018-07-20 19:05:56 -07:00
|
|
|
bool lastLine = _fonts._font2->getLine(lines, s->_maxChars * 6, line, width);
|
2014-08-31 02:18:02 +02:00
|
|
|
|
|
|
|
// Set font colors
|
2018-07-20 19:05:56 -07:00
|
|
|
_fonts._font2->_fontColors[0] = 0;
|
|
|
|
_fonts._font2->_fontColors[1] = 28;
|
|
|
|
_fonts._font2->_fontColors[2] = 29;
|
|
|
|
_fonts._font2->_fontColors[3] = 30;
|
|
|
|
_fonts._font2->drawString(s, line, s->_printOrg);
|
2014-08-31 02:18:02 +02:00
|
|
|
|
2014-11-10 10:29:39 +01:00
|
|
|
s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9);
|
2014-08-31 02:18:02 +02:00
|
|
|
|
2014-11-10 10:29:39 +01:00
|
|
|
if (s->_printOrg.y >_printEnd && !lastLine) {
|
|
|
|
_events->waitKeyMouse();
|
|
|
|
s->copyBuffer(&_buffer2);
|
|
|
|
s->_printOrg.y = s->_printStart.y;
|
|
|
|
}
|
2014-08-31 02:18:02 +02:00
|
|
|
|
|
|
|
if (lastLine)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
_events->waitKeyMouse();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-11 23:12:53 -04:00
|
|
|
void AccessEngine::plotList() {
|
|
|
|
_player->calcPlayer();
|
|
|
|
plotList1();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AccessEngine::plotList1() {
|
|
|
|
for (uint idx = 0; idx < _images.size(); ++idx) {
|
|
|
|
ImageEntry &ie = _images[idx];
|
|
|
|
|
2014-11-22 22:17:39 -05:00
|
|
|
_imgUnscaled = (ie._flags & IMGFLAG_UNSCALED) != 0;
|
2014-08-11 23:12:53 -04:00
|
|
|
Common::Point pt = ie._position - _screen->_bufferStart;
|
|
|
|
SpriteResource *sprites = ie._spritesPtr;
|
|
|
|
SpriteFrame *frame = sprites->getFrame(ie._frameNumber);
|
|
|
|
|
|
|
|
Common::Rect bounds(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h);
|
2014-11-22 22:17:39 -05:00
|
|
|
if (!_imgUnscaled) {
|
2014-08-11 23:12:53 -04:00
|
|
|
bounds.setWidth(_screen->_scaleTable1[frame->w]);
|
|
|
|
bounds.setHeight(_screen->_scaleTable1[frame->h]);
|
|
|
|
}
|
|
|
|
|
2014-08-16 15:47:25 -04:00
|
|
|
// Make a copy - some of the drawing methods I've adapted need the full
|
|
|
|
// scaled dimensions on-screen, and handle clipping themselves
|
|
|
|
Common::Rect destBounds = bounds;
|
|
|
|
|
2014-08-11 23:12:53 -04:00
|
|
|
if (_buffer2.clip(bounds)) {
|
2014-11-26 18:33:03 -05:00
|
|
|
ie._flags |= IMGFLAG_CROPPED;
|
2014-08-11 23:12:53 -04:00
|
|
|
} else {
|
2014-11-26 18:33:03 -05:00
|
|
|
ie._flags &= ~IMGFLAG_CROPPED;
|
2014-08-11 23:12:53 -04:00
|
|
|
if (_buffer2._leftSkip != 0 || _buffer2._rightSkip != 0
|
|
|
|
|| _buffer2._topSkip != 0 || _buffer2._bottomSkip != 0)
|
2014-11-26 18:33:03 -05:00
|
|
|
ie._flags |= IMGFLAG_CROPPED;
|
2014-08-11 23:12:53 -04:00
|
|
|
|
2014-08-12 08:38:12 -04:00
|
|
|
_newRects.push_back(bounds);
|
2014-08-11 23:12:53 -04:00
|
|
|
|
2014-11-22 22:17:39 -05:00
|
|
|
if (!_imgUnscaled) {
|
2014-08-11 23:12:53 -04:00
|
|
|
_buffer2._rightSkip /= _scale;
|
|
|
|
bounds.setWidth(bounds.width() / _scale);
|
|
|
|
|
2014-11-26 18:33:03 -05:00
|
|
|
if (ie._flags & IMGFLAG_BACKWARDS) {
|
2014-08-18 20:15:43 -04:00
|
|
|
_buffer2.sPlotB(frame, destBounds);
|
2014-08-11 23:12:53 -04:00
|
|
|
} else {
|
2014-08-16 15:47:25 -04:00
|
|
|
_buffer2.sPlotF(frame, destBounds);
|
2014-08-11 23:12:53 -04:00
|
|
|
}
|
|
|
|
} else {
|
2014-11-22 22:17:39 -05:00
|
|
|
if (ie._flags & IMGFLAG_BACKWARDS) {
|
2014-08-30 14:19:49 -04:00
|
|
|
_buffer2.plotB(frame, Common::Point(destBounds.left, destBounds.top));
|
2014-08-11 23:12:53 -04:00
|
|
|
} else {
|
2014-08-30 14:19:49 -04:00
|
|
|
_buffer2.plotF(frame, Common::Point(destBounds.left, destBounds.top));
|
2014-08-11 23:12:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-26 18:33:03 -05:00
|
|
|
|
|
|
|
ie._flags |= IMGFLAG_DRAWN;
|
2014-08-11 23:12:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-12 08:38:12 -04:00
|
|
|
void AccessEngine::copyBlocks() {
|
|
|
|
// Copy the block list from the previous frame
|
|
|
|
for (uint i = 0; i < _oldRects.size(); ++i) {
|
|
|
|
_screen->copyBlock(&_buffer2, _oldRects[i]);
|
|
|
|
}
|
|
|
|
|
2014-08-12 21:40:14 -04:00
|
|
|
copyRects();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AccessEngine::copyRects() {
|
2014-08-12 08:38:12 -04:00
|
|
|
_oldRects.clear();
|
|
|
|
for (uint i = 0; i < _newRects.size(); ++i) {
|
|
|
|
_screen->copyBlock(&_buffer2, _newRects[i]);
|
|
|
|
_oldRects.push_back(_newRects[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-12 23:34:23 -04:00
|
|
|
void AccessEngine::copyBF1BF2() {
|
2014-08-13 20:56:06 -04:00
|
|
|
_buffer2.copyRectToSurface(_buffer1, 0, 0,
|
2014-12-18 21:45:55 -05:00
|
|
|
Common::Rect(_scrollX, _scrollY,
|
|
|
|
_scrollX + _screen->_vWindowBytesWide,
|
|
|
|
_scrollY + _screen->_vWindowLinesTall));
|
2014-08-12 23:34:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void AccessEngine::copyBF2Vid() {
|
2016-03-10 21:51:06 -05:00
|
|
|
_screen->blitFrom(_buffer2,
|
|
|
|
Common::Rect(0, 0, _screen->_vWindowBytesWide, _screen->_vWindowLinesTall),
|
|
|
|
Common::Point(_screen->_windowXAdd, _screen->_windowYAdd));
|
2014-08-12 23:34:23 -04:00
|
|
|
}
|
|
|
|
|
2014-11-01 16:07:52 -04:00
|
|
|
void AccessEngine::playVideo(int videoNum, const Common::Point &pt) {
|
|
|
|
_video->setVideo(_screen, pt, FileIdent(96, videoNum), 10);
|
2014-10-31 23:01:47 -04:00
|
|
|
|
|
|
|
while (!shouldQuit() && !_video->_videoEnd) {
|
|
|
|
_video->playVideo();
|
2014-12-10 21:27:06 -05:00
|
|
|
_events->pollEventsAndWait();
|
2014-10-31 23:01:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-19 20:43:32 -04:00
|
|
|
void AccessEngine::freeChar() {
|
|
|
|
_scripts->freeScriptData();
|
|
|
|
_animation->clearTimers();
|
|
|
|
_animation->freeAnimationData();
|
|
|
|
}
|
|
|
|
|
2020-02-04 22:13:33 -08:00
|
|
|
Common::Error AccessEngine::saveGameState(int slot, const Common::String &desc, bool isAutosave) {
|
2014-08-30 09:57:51 -04:00
|
|
|
Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(
|
2020-02-06 21:54:41 -08:00
|
|
|
getSaveStateName(slot));
|
2014-08-30 09:57:51 -04:00
|
|
|
if (!out)
|
|
|
|
return Common::kCreatingFileFailed;
|
|
|
|
|
|
|
|
AccessSavegameHeader header;
|
|
|
|
header._saveName = desc;
|
|
|
|
writeSavegameHeader(out, header);
|
|
|
|
|
|
|
|
Common::Serializer s(nullptr, out);
|
|
|
|
synchronize(s);
|
|
|
|
|
|
|
|
out->finalize();
|
|
|
|
delete out;
|
|
|
|
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error AccessEngine::loadGameState(int slot) {
|
|
|
|
Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(
|
2020-02-06 21:54:41 -08:00
|
|
|
getSaveStateName(slot));
|
2014-08-30 09:57:51 -04:00
|
|
|
if (!saveFile)
|
|
|
|
return Common::kReadingFailed;
|
|
|
|
|
|
|
|
Common::Serializer s(saveFile, nullptr);
|
|
|
|
|
|
|
|
// Load the savaegame header
|
|
|
|
AccessSavegameHeader header;
|
|
|
|
if (!readSavegameHeader(saveFile, header))
|
|
|
|
error("Invalid savegame");
|
|
|
|
|
|
|
|
// Load most of the savegame data
|
|
|
|
synchronize(s);
|
|
|
|
delete saveFile;
|
|
|
|
|
|
|
|
// Set extra post-load state
|
2014-11-27 21:35:20 -05:00
|
|
|
_room->_function = FN_CLEAR1;
|
2014-08-30 09:57:51 -04:00
|
|
|
_timers._timersSavedFlag = false;
|
2014-11-27 16:56:03 -05:00
|
|
|
_events->clearEvents();
|
2014-08-30 09:57:51 -04:00
|
|
|
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AccessEngine::canLoadGameStateCurrently() {
|
|
|
|
return _canSaveLoad;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AccessEngine::canSaveGameStateCurrently() {
|
|
|
|
return _canSaveLoad;
|
|
|
|
}
|
|
|
|
|
2014-08-29 21:03:11 -04:00
|
|
|
void AccessEngine::synchronize(Common::Serializer &s) {
|
|
|
|
s.syncAsUint16LE(_conversation);
|
|
|
|
s.syncAsUint16LE(_currentMan);
|
|
|
|
s.syncAsUint32LE(_newTime);
|
|
|
|
s.syncAsUint32LE(_newDate);
|
|
|
|
|
|
|
|
for (int i = 0; i < 256; ++i)
|
|
|
|
s.syncAsUint16LE(_flags[i]);
|
2014-11-01 13:43:11 -04:00
|
|
|
for (int i = 0; i < 100; ++i)
|
|
|
|
s.syncAsByte(_establishTable[i]);
|
|
|
|
|
2014-08-29 21:03:11 -04:00
|
|
|
// Synchronize sub-objects
|
|
|
|
_timers.synchronize(s);
|
|
|
|
_inventory->synchronize(s);
|
|
|
|
_player->synchronize(s);
|
|
|
|
}
|
|
|
|
|
2014-08-30 08:45:42 -04:00
|
|
|
const char *const SAVEGAME_STR = "ACCESS";
|
|
|
|
#define SAVEGAME_STR_SIZE 6
|
|
|
|
|
ALL: Load savegame thumbnail only when necessary
This commit introduces the following changes:
1. Graphics::loadThumbnail()
Now returns a boolean and takes a new argument skipThumbnail which
defaults to false. In case of true, loadThumbnail() reads past the
thumbnail data in the input stream instead of actually loading the
thumbnail. This simplifies savegame handling where, up until now,
many engines always read the whole savegame metadata (including
the thumbnail) and then threw away the thumbnail when not needed
(which is in almost all cases, the most common exception being
MetaEngine::querySaveMetaInfos() which is responsible for loading
savegame metadata for displaying it in the GUI launcher.
2. readSavegameHeader()
Engines which already implement such a method (name varies) now take
a new argument skipThumbnail (default: true) which is passed
through to loadThumbnail(). This means that the default case for
readSavegameHeader() is now _not_ loading the thumbnail from a
savegame and just reading past it. In those cases, e.g.
querySaveMetaInfos(), where we actually are interested in loading
the thumbnail readSavegameHeader() needs to explicitely be called
with skipThumbnail == false.
Engines whose readSavegameHeader() (name varies) already takes an
argument loadThumbnail have been adapted to have a similar
prototype and semantics.
I.e. readSaveHeader(in, loadThumbnail, header) now is
readSaveHeader(in, header, skipThumbnail).
3. Error handling
Engines which previously did not check the return value of
readSavegameHeader() (name varies) now do so ensuring that possibly
broken savegames (be it a broken thumbnail or something else) don't
make it into the GUI launcher list in the first place.
2018-04-06 00:06:38 +02:00
|
|
|
WARN_UNUSED_RESULT bool AccessEngine::readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header, bool skipThumbnail) {
|
2014-08-30 08:45:42 -04:00
|
|
|
char saveIdentBuffer[SAVEGAME_STR_SIZE + 1];
|
|
|
|
|
|
|
|
// Validate the header Id
|
|
|
|
in->read(saveIdentBuffer, SAVEGAME_STR_SIZE + 1);
|
|
|
|
if (strncmp(saveIdentBuffer, SAVEGAME_STR, SAVEGAME_STR_SIZE))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
header._version = in->readByte();
|
|
|
|
if (header._version > ACCESS_SAVEGAME_VERSION)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Read in the string
|
|
|
|
header._saveName.clear();
|
|
|
|
char ch;
|
2014-12-17 07:47:55 +01:00
|
|
|
while ((ch = (char)in->readByte()) != '\0')
|
|
|
|
header._saveName += ch;
|
2014-08-30 08:45:42 -04:00
|
|
|
|
|
|
|
// Get the thumbnail
|
ALL: Load savegame thumbnail only when necessary
This commit introduces the following changes:
1. Graphics::loadThumbnail()
Now returns a boolean and takes a new argument skipThumbnail which
defaults to false. In case of true, loadThumbnail() reads past the
thumbnail data in the input stream instead of actually loading the
thumbnail. This simplifies savegame handling where, up until now,
many engines always read the whole savegame metadata (including
the thumbnail) and then threw away the thumbnail when not needed
(which is in almost all cases, the most common exception being
MetaEngine::querySaveMetaInfos() which is responsible for loading
savegame metadata for displaying it in the GUI launcher.
2. readSavegameHeader()
Engines which already implement such a method (name varies) now take
a new argument skipThumbnail (default: true) which is passed
through to loadThumbnail(). This means that the default case for
readSavegameHeader() is now _not_ loading the thumbnail from a
savegame and just reading past it. In those cases, e.g.
querySaveMetaInfos(), where we actually are interested in loading
the thumbnail readSavegameHeader() needs to explicitely be called
with skipThumbnail == false.
Engines whose readSavegameHeader() (name varies) already takes an
argument loadThumbnail have been adapted to have a similar
prototype and semantics.
I.e. readSaveHeader(in, loadThumbnail, header) now is
readSaveHeader(in, header, skipThumbnail).
3. Error handling
Engines which previously did not check the return value of
readSavegameHeader() (name varies) now do so ensuring that possibly
broken savegames (be it a broken thumbnail or something else) don't
make it into the GUI launcher list in the first place.
2018-04-06 00:06:38 +02:00
|
|
|
if (!Graphics::loadThumbnail(*in, header._thumbnail, skipThumbnail)) {
|
2014-08-30 08:45:42 -04:00
|
|
|
return false;
|
ALL: Load savegame thumbnail only when necessary
This commit introduces the following changes:
1. Graphics::loadThumbnail()
Now returns a boolean and takes a new argument skipThumbnail which
defaults to false. In case of true, loadThumbnail() reads past the
thumbnail data in the input stream instead of actually loading the
thumbnail. This simplifies savegame handling where, up until now,
many engines always read the whole savegame metadata (including
the thumbnail) and then threw away the thumbnail when not needed
(which is in almost all cases, the most common exception being
MetaEngine::querySaveMetaInfos() which is responsible for loading
savegame metadata for displaying it in the GUI launcher.
2. readSavegameHeader()
Engines which already implement such a method (name varies) now take
a new argument skipThumbnail (default: true) which is passed
through to loadThumbnail(). This means that the default case for
readSavegameHeader() is now _not_ loading the thumbnail from a
savegame and just reading past it. In those cases, e.g.
querySaveMetaInfos(), where we actually are interested in loading
the thumbnail readSavegameHeader() needs to explicitely be called
with skipThumbnail == false.
Engines whose readSavegameHeader() (name varies) already takes an
argument loadThumbnail have been adapted to have a similar
prototype and semantics.
I.e. readSaveHeader(in, loadThumbnail, header) now is
readSaveHeader(in, header, skipThumbnail).
3. Error handling
Engines which previously did not check the return value of
readSavegameHeader() (name varies) now do so ensuring that possibly
broken savegames (be it a broken thumbnail or something else) don't
make it into the GUI launcher list in the first place.
2018-04-06 00:06:38 +02:00
|
|
|
}
|
2014-08-30 08:45:42 -04:00
|
|
|
|
|
|
|
// Read in save date/time
|
|
|
|
header._year = in->readSint16LE();
|
|
|
|
header._month = in->readSint16LE();
|
|
|
|
header._day = in->readSint16LE();
|
|
|
|
header._hour = in->readSint16LE();
|
|
|
|
header._minute = in->readSint16LE();
|
|
|
|
header._totalFrames = in->readUint32LE();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AccessEngine::writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameHeader &header) {
|
|
|
|
// Write out a savegame header
|
|
|
|
out->write(SAVEGAME_STR, SAVEGAME_STR_SIZE + 1);
|
|
|
|
|
|
|
|
out->writeByte(ACCESS_SAVEGAME_VERSION);
|
|
|
|
|
|
|
|
// Write savegame name
|
2014-12-17 18:25:24 +01:00
|
|
|
out->writeString(header._saveName);
|
2014-08-30 08:45:42 -04:00
|
|
|
out->writeByte('\0');
|
|
|
|
|
|
|
|
// Write a thumbnail of the screen
|
|
|
|
uint8 thumbPalette[PALETTE_SIZE];
|
|
|
|
_screen->getPalette(thumbPalette);
|
|
|
|
Graphics::Surface saveThumb;
|
|
|
|
::createThumbnail(&saveThumb, (const byte *)_screen->getPixels(),
|
|
|
|
_screen->w, _screen->h, thumbPalette);
|
|
|
|
Graphics::saveThumbnail(*out, saveThumb);
|
|
|
|
saveThumb.free();
|
|
|
|
|
|
|
|
// Write out the save date/time
|
|
|
|
TimeDate td;
|
|
|
|
g_system->getTimeAndDate(td);
|
|
|
|
out->writeSint16LE(td.tm_year + 1900);
|
|
|
|
out->writeSint16LE(td.tm_mon + 1);
|
|
|
|
out->writeSint16LE(td.tm_mday);
|
|
|
|
out->writeSint16LE(td.tm_hour);
|
|
|
|
out->writeSint16LE(td.tm_min);
|
|
|
|
out->writeUint32LE(_events->getFrameCounter());
|
|
|
|
}
|
|
|
|
|
2015-02-06 08:25:22 +01:00
|
|
|
void AccessEngine::SPRINTCHR(char c, int fontNum) {
|
|
|
|
warning("TODO: SPRINTCHR");
|
2018-07-20 19:05:56 -07:00
|
|
|
_fonts._font1->drawChar(_screen, c, _screen->_printOrg);
|
2015-02-06 08:25:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void AccessEngine::PRINTCHR(Common::String msg, int fontNum) {
|
|
|
|
_events->hideCursor();
|
|
|
|
warning("TODO: PRINTCHR - Handle fontNum");
|
|
|
|
|
|
|
|
for (int i = 0; msg[i]; i++) {
|
|
|
|
if (!(_fonts._charSet._hi & 8)) {
|
2018-07-20 19:05:56 -07:00
|
|
|
_fonts._font1->drawChar(_screen, msg[i], _screen->_printOrg);
|
2015-02-06 08:25:22 +01:00
|
|
|
continue;
|
|
|
|
} else if (_fonts._charSet._hi & 2) {
|
|
|
|
Common::Point oldPos = _screen->_printOrg;
|
|
|
|
int oldFontLo = _fonts._charFor._lo;
|
|
|
|
|
|
|
|
_fonts._charFor._lo = 0;
|
|
|
|
_screen->_printOrg.x++;
|
|
|
|
_screen->_printOrg.y++;
|
|
|
|
SPRINTCHR(msg[i], fontNum);
|
|
|
|
|
|
|
|
_screen->_printOrg = oldPos;
|
|
|
|
_fonts._charFor._lo = oldFontLo;
|
|
|
|
}
|
|
|
|
SPRINTCHR(msg[i], fontNum);
|
|
|
|
}
|
|
|
|
_events->showCursor();
|
|
|
|
}
|
|
|
|
|
2014-12-10 23:25:18 +01:00
|
|
|
bool AccessEngine::shouldQuitOrRestart() {
|
|
|
|
return shouldQuit() || _restartFl;
|
|
|
|
}
|
2014-07-29 21:02:28 -04:00
|
|
|
} // End of namespace Access
|