2016-06-03 21:58:25 +02: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.
|
|
|
|
*
|
|
|
|
*/
|
2016-06-04 20:53:01 +02:00
|
|
|
|
2016-06-05 20:55:29 +02:00
|
|
|
#include "common/system.h"
|
2016-06-05 20:45:14 +02:00
|
|
|
#include "common/debug-channels.h"
|
|
|
|
#include "common/debug.h"
|
2016-06-04 20:53:01 +02:00
|
|
|
#include "common/error.h"
|
2016-06-05 20:45:14 +02:00
|
|
|
#include "engines/util.h"
|
2016-06-04 20:53:01 +02:00
|
|
|
|
|
|
|
#include "macventure/macventure.h"
|
|
|
|
|
2016-06-08 16:07:53 +02:00
|
|
|
// To move
|
|
|
|
#include "common/file.h"
|
|
|
|
|
2016-06-04 20:53:01 +02:00
|
|
|
namespace MacVenture {
|
|
|
|
|
2016-06-08 16:07:53 +02:00
|
|
|
enum {
|
|
|
|
kMaxMenuTitleLength = 30
|
|
|
|
};
|
|
|
|
|
2016-06-12 23:08:24 +02:00
|
|
|
enum {
|
|
|
|
kGlobalSettingsID = 0x80,
|
|
|
|
kDiplomaGeometryID = 0x81,
|
|
|
|
kTextHuffmanTableID = 0x83
|
|
|
|
};
|
|
|
|
|
2016-06-04 20:53:01 +02:00
|
|
|
MacVentureEngine::MacVentureEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst) {
|
|
|
|
_gameDescription = gameDesc;
|
2016-06-05 20:45:14 +02:00
|
|
|
_rnd = new Common::RandomSource("macventure");
|
|
|
|
|
|
|
|
_debugger= NULL;
|
|
|
|
|
|
|
|
debug("MacVenture::MacVentureEngine()");
|
2016-06-04 20:53:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MacVentureEngine::~MacVentureEngine() {
|
2016-06-05 20:45:14 +02:00
|
|
|
debug("MacVenture::~MacVentureEngine()");
|
|
|
|
|
|
|
|
DebugMan.clearAllDebugChannels();
|
|
|
|
delete _rnd;
|
|
|
|
delete _debugger;
|
2016-06-08 11:02:21 +02:00
|
|
|
delete _gui;
|
2016-06-04 20:53:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error MacVentureEngine::run() {
|
2016-06-05 20:45:14 +02:00
|
|
|
debug("MacVenture::MacVentureEngine::init()");
|
|
|
|
|
2016-06-08 11:02:21 +02:00
|
|
|
initGraphics(kScreenWidth, kScreenHeight, true);
|
2016-06-05 20:45:14 +02:00
|
|
|
|
|
|
|
_debugger = new Console(this);
|
|
|
|
|
|
|
|
// Additional setup.
|
2016-06-08 17:13:02 +02:00
|
|
|
debug("MacVentureEngine::init");
|
2016-06-05 20:55:29 +02:00
|
|
|
|
2016-06-08 11:17:56 +02:00
|
|
|
_resourceManager = new Common::MacResManager();
|
|
|
|
if (!_resourceManager->open(getGameFileName()))
|
|
|
|
error("Could not open %s as a resource fork", getGameFileName());
|
|
|
|
|
2016-06-12 23:08:24 +02:00
|
|
|
if (!loadGlobalSettings())
|
|
|
|
error("Could not load the engine settings");
|
|
|
|
|
2016-06-08 17:13:02 +02:00
|
|
|
_gui = new Gui(this, _resourceManager);
|
2016-06-08 16:07:53 +02:00
|
|
|
|
2016-06-05 20:55:29 +02:00
|
|
|
_shouldQuit = false;
|
|
|
|
while (!_shouldQuit) {
|
|
|
|
processEvents();
|
|
|
|
|
2016-06-08 11:02:21 +02:00
|
|
|
_gui->draw();
|
2016-06-05 20:55:29 +02:00
|
|
|
|
|
|
|
g_system->updateScreen();
|
|
|
|
g_system->delayMillis(50);
|
|
|
|
}
|
2016-06-05 20:45:14 +02:00
|
|
|
|
|
|
|
return Common::kNoError;
|
2016-06-04 20:53:01 +02:00
|
|
|
}
|
|
|
|
|
2016-06-12 23:08:24 +02:00
|
|
|
bool MacVentureEngine::loadGlobalSettings() {
|
|
|
|
Common::MacResIDArray resArray;
|
|
|
|
Common::SeekableReadStream *res;
|
|
|
|
|
|
|
|
if ((resArray = _resourceManager->getResIDArray(MKTAG('G', 'N', 'R', 'L'))).size() == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
res = _resourceManager->getResource(MKTAG('G', 'N', 'R', 'L'), kGlobalSettingsID);
|
|
|
|
if (res) {
|
|
|
|
_globalSettings.numObjects = res->readUint16BE();
|
|
|
|
_globalSettings.numGlobals = res->readUint16BE();
|
|
|
|
_globalSettings.numCommands = res->readUint16BE();
|
|
|
|
_globalSettings.numAttributes = res->readUint16BE();
|
|
|
|
_globalSettings.numGroups = res->readUint16BE();
|
|
|
|
res->readUint16BE(); // unknown
|
|
|
|
_globalSettings.invTop = res->readUint16BE();
|
|
|
|
_globalSettings.invLeft = res->readUint16BE();
|
|
|
|
_globalSettings.invWidth = res->readUint16BE();
|
|
|
|
_globalSettings.invHeight = res->readUint16BE();
|
|
|
|
_globalSettings.invOffsetY = res->readUint16BE();
|
|
|
|
_globalSettings.invOffsetX = res->readSint16BE();
|
|
|
|
_globalSettings.defaultFont = res->readUint16BE();
|
|
|
|
_globalSettings.defaultSize = res->readUint16BE();
|
|
|
|
|
|
|
|
_globalSettings.attrIndices = new uint8[_globalSettings.numAttributes];
|
|
|
|
res->read(_globalSettings.attrIndices, _globalSettings.numAttributes);
|
|
|
|
|
|
|
|
_globalSettings.attrMasks = new uint16[_globalSettings.numAttributes];
|
|
|
|
for (int i = 0; i < _globalSettings.numAttributes; i++)
|
|
|
|
_globalSettings.attrMasks[i] = res->readUint16BE();
|
|
|
|
|
|
|
|
_globalSettings.attrShifts = new uint8[_globalSettings.numAttributes];
|
|
|
|
res->read(_globalSettings.attrShifts, _globalSettings.numAttributes);
|
|
|
|
|
|
|
|
_globalSettings.cmdArgCnts = new uint8[_globalSettings.numCommands];
|
|
|
|
res->read(_globalSettings.cmdArgCnts, _globalSettings.numCommands);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-12 22:09:06 +02:00
|
|
|
void MacVentureEngine::requestQuit() {
|
|
|
|
_shouldQuit = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MacVentureEngine::requestUnpause() {
|
|
|
|
_paused = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Data retrieval
|
|
|
|
|
|
|
|
bool MacVentureEngine::isPaused() {
|
|
|
|
return _paused;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::String MacVentureEngine::getCommandsPausedString() {
|
|
|
|
return Common::String("Click to continue");
|
|
|
|
}
|
|
|
|
|
2016-06-05 20:55:29 +02:00
|
|
|
void MacVentureEngine::processEvents() {
|
|
|
|
Common::Event event;
|
|
|
|
|
|
|
|
while (_eventMan->pollEvent(event)) {
|
2016-06-08 17:13:02 +02:00
|
|
|
if (_gui->processEvent(event))
|
|
|
|
continue;
|
|
|
|
|
2016-06-05 20:55:29 +02:00
|
|
|
switch (event.type) {
|
2016-06-08 17:13:02 +02:00
|
|
|
case Common::EVENT_QUIT:
|
|
|
|
_shouldQuit = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2016-06-05 20:55:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-06-08 11:17:56 +02:00
|
|
|
|
|
|
|
|
2016-06-04 20:53:01 +02:00
|
|
|
} // End of namespace MacVenture
|