2007-07-29 14:24:31 +00: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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-08-09 19:26:20 +00:00
|
|
|
#include "common/system.h"
|
2007-09-19 08:40:12 +00:00
|
|
|
#include "common/util.h"
|
2007-08-09 19:26:20 +00:00
|
|
|
|
2007-07-29 14:24:31 +00:00
|
|
|
#include "parallaction/parallaction.h"
|
2008-05-14 14:34:01 +00:00
|
|
|
#include "parallaction/input.h"
|
2007-07-29 14:24:31 +00:00
|
|
|
#include "parallaction/sound.h"
|
|
|
|
|
|
|
|
namespace Parallaction {
|
|
|
|
|
2007-08-12 12:24:59 +00:00
|
|
|
|
2008-02-02 12:36:06 +00:00
|
|
|
const char *Parallaction_br::_partNames[] = {
|
2007-08-12 13:27:48 +00:00
|
|
|
"PART0",
|
|
|
|
"PART1",
|
|
|
|
"PART2",
|
|
|
|
"PART3",
|
|
|
|
"PART4"
|
|
|
|
};
|
|
|
|
|
2007-07-29 14:24:31 +00:00
|
|
|
int Parallaction_br::init() {
|
|
|
|
|
|
|
|
_screenWidth = 640;
|
|
|
|
_screenHeight = 400;
|
|
|
|
|
|
|
|
if (getGameType() == GType_BRA) {
|
|
|
|
if (getPlatform() == Common::kPlatformPC) {
|
2008-07-28 07:20:55 +00:00
|
|
|
if (getFeatures() & GF_DEMO) {
|
|
|
|
_disk = new DosDemo_br(this);
|
|
|
|
} else {
|
|
|
|
_disk = new DosDisk_br(this);
|
|
|
|
}
|
2007-08-12 13:54:01 +00:00
|
|
|
_disk->setLanguage(2); // NOTE: language is now hardcoded to English. Original used command-line parameters.
|
2008-04-06 07:05:56 +00:00
|
|
|
_soundMan = new DummySoundMan(this);
|
|
|
|
} else {
|
|
|
|
_disk = new AmigaDisk_br(this);
|
|
|
|
_disk->setLanguage(2); // NOTE: language is now hardcoded to English. Original used command-line parameters.
|
|
|
|
_soundMan = new AmigaSoundMan(this);
|
|
|
|
}
|
|
|
|
} else {
|
2007-07-29 14:24:31 +00:00
|
|
|
error("unknown game type");
|
2008-04-06 07:05:56 +00:00
|
|
|
}
|
2007-07-29 14:24:31 +00:00
|
|
|
|
|
|
|
|
2007-07-29 16:29:41 +00:00
|
|
|
initResources();
|
2007-08-11 17:25:57 +00:00
|
|
|
initFonts();
|
2008-05-10 11:11:03 +00:00
|
|
|
_locationParser = new LocationParser_br(this);
|
2008-06-03 00:49:27 +00:00
|
|
|
_locationParser->init();
|
2008-05-10 11:11:03 +00:00
|
|
|
_programParser = new ProgramParser_br(this);
|
2008-06-03 00:49:27 +00:00
|
|
|
_programParser->init();
|
2007-08-26 09:01:19 +00:00
|
|
|
|
2008-07-11 13:06:28 +00:00
|
|
|
_cmdExec = new CommandExec_br(this);
|
|
|
|
_cmdExec->init();
|
|
|
|
_programExec = new ProgramExec_br(this);
|
|
|
|
_programExec->init();
|
|
|
|
|
2007-08-12 13:10:04 +00:00
|
|
|
_part = -1;
|
|
|
|
|
2008-07-04 00:29:21 +00:00
|
|
|
_subtitle[0] = -1;
|
|
|
|
_subtitle[1] = -1;
|
|
|
|
|
2007-07-29 14:24:31 +00:00
|
|
|
Parallaction::init();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-11 17:25:57 +00:00
|
|
|
Parallaction_br::~Parallaction_br() {
|
|
|
|
freeFonts();
|
|
|
|
}
|
|
|
|
|
2007-07-29 18:49:24 +00:00
|
|
|
void Parallaction_br::callFunction(uint index, void* parm) {
|
|
|
|
assert(index < 6); // magic value 6 is maximum # of callables for Big Red Adventure
|
|
|
|
|
|
|
|
(this->*_callables[index])(parm);
|
|
|
|
}
|
|
|
|
|
2007-08-09 19:26:20 +00:00
|
|
|
int Parallaction_br::go() {
|
|
|
|
|
2008-08-20 04:02:12 +00:00
|
|
|
bool splash = true;
|
2008-02-05 10:24:22 +00:00
|
|
|
|
2007-08-12 13:10:04 +00:00
|
|
|
while ((_engineFlags & kEngineQuit) == 0) {
|
|
|
|
|
2008-08-20 04:02:12 +00:00
|
|
|
if (getFeatures() & GF_DEMO) {
|
2008-08-31 05:18:25 +00:00
|
|
|
scheduleLocationSwitch("camalb.1");
|
2008-08-20 04:02:12 +00:00
|
|
|
_input->_inputMode = Input::kInputModeGame;
|
|
|
|
} else {
|
|
|
|
startGui(splash);
|
|
|
|
// don't show splash after first time
|
|
|
|
splash = false;
|
|
|
|
}
|
|
|
|
|
2008-02-02 12:36:06 +00:00
|
|
|
// initCharacter();
|
2007-08-12 13:10:04 +00:00
|
|
|
|
2008-02-05 10:24:22 +00:00
|
|
|
while ((_engineFlags & (kEngineReturn | kEngineQuit)) == 0) {
|
|
|
|
runGame();
|
|
|
|
}
|
|
|
|
_engineFlags &= ~kEngineReturn;
|
2007-08-11 19:08:32 +00:00
|
|
|
|
2007-08-12 13:10:04 +00:00
|
|
|
freePart();
|
|
|
|
// freeCharacter();
|
|
|
|
}
|
2007-08-11 19:08:32 +00:00
|
|
|
|
2007-08-09 19:26:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-11 19:08:32 +00:00
|
|
|
|
2007-08-11 17:25:57 +00:00
|
|
|
|
|
|
|
void Parallaction_br::freeFonts() {
|
|
|
|
|
|
|
|
delete _menuFont;
|
|
|
|
delete _dialogueFont;
|
|
|
|
|
|
|
|
return;
|
2007-08-11 20:44:22 +00:00
|
|
|
}
|
|
|
|
|
2007-08-11 21:08:08 +00:00
|
|
|
|
2007-08-12 13:10:04 +00:00
|
|
|
void Parallaction_br::initPart() {
|
|
|
|
|
2007-08-24 20:14:51 +00:00
|
|
|
memset(_counters, 0, ARRAYSIZE(_counters));
|
|
|
|
|
2008-08-14 13:45:32 +00:00
|
|
|
_globalFlagsNames = _disk->loadTable("global");
|
2007-08-12 13:27:48 +00:00
|
|
|
_objectsNames = _disk->loadTable("objects");
|
|
|
|
_countersNames = _disk->loadTable("counters");
|
|
|
|
|
2008-07-28 05:18:23 +00:00
|
|
|
// TODO: maybe handle this into Disk
|
|
|
|
if (getPlatform() == Common::kPlatformPC) {
|
|
|
|
_char._objs = _disk->loadObjects("icone.ico");
|
|
|
|
} else {
|
|
|
|
_char._objs = _disk->loadObjects("icons.ico");
|
|
|
|
}
|
2007-08-12 13:10:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction_br::freePart() {
|
2008-08-21 12:11:24 +00:00
|
|
|
freeLocation();
|
2007-08-12 13:10:04 +00:00
|
|
|
|
2008-08-14 13:45:32 +00:00
|
|
|
delete _globalFlagsNames;
|
2007-08-12 13:27:48 +00:00
|
|
|
delete _objectsNames;
|
|
|
|
delete _countersNames;
|
2007-08-12 13:10:04 +00:00
|
|
|
|
2008-08-14 13:45:32 +00:00
|
|
|
_globalFlagsNames = 0;
|
2007-11-18 13:22:38 +00:00
|
|
|
_objectsNames = 0;
|
|
|
|
_countersNames = 0;
|
2007-08-12 13:10:04 +00:00
|
|
|
}
|
|
|
|
|
2008-02-02 22:45:31 +00:00
|
|
|
void Parallaction_br::runPendingZones() {
|
2008-04-06 05:40:02 +00:00
|
|
|
ZonePtr z;
|
2008-02-02 22:45:31 +00:00
|
|
|
|
2008-07-29 12:59:55 +00:00
|
|
|
_cmdExec->runSuspended();
|
|
|
|
|
2008-02-02 22:45:31 +00:00
|
|
|
if (_activeZone) {
|
|
|
|
z = _activeZone; // speak Zone or sound
|
2008-04-06 05:40:02 +00:00
|
|
|
_activeZone = nullZonePtr;
|
2008-07-21 06:08:30 +00:00
|
|
|
if ((z->_type & 0xFFFF) == kZoneSpeak) {
|
|
|
|
enterDialogueMode(z);
|
|
|
|
} else {
|
|
|
|
runZone(z); // FIXME: BRA doesn't handle sound yet
|
|
|
|
}
|
2008-02-02 22:45:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_activeZone2) {
|
|
|
|
z = _activeZone2; // speak Zone or sound
|
2008-04-06 05:40:02 +00:00
|
|
|
_activeZone2 = nullZonePtr;
|
2008-07-21 06:08:30 +00:00
|
|
|
if ((z->_type & 0xFFFF) == kZoneSpeak) {
|
|
|
|
enterDialogueMode(z);
|
|
|
|
} else {
|
|
|
|
runZone(z); // FIXME: BRA doesn't handle sound yet
|
|
|
|
}
|
2008-02-02 22:45:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-21 12:11:24 +00:00
|
|
|
void Parallaction_br::freeLocation() {
|
2007-08-25 20:34:10 +00:00
|
|
|
|
2008-02-02 22:45:31 +00:00
|
|
|
// free open location stuff
|
|
|
|
clearSubtitles();
|
2008-02-03 10:48:07 +00:00
|
|
|
freeBackground();
|
2008-07-25 08:27:44 +00:00
|
|
|
_gfx->clearGfxObjects(kGfxObjNormal);
|
2008-07-28 14:23:49 +00:00
|
|
|
_gfx->freeLabels();
|
|
|
|
_subtitle[0] = _subtitle[1] = -1;
|
|
|
|
|
2008-05-05 11:02:40 +00:00
|
|
|
_location._programs.clear();
|
2008-07-11 13:06:28 +00:00
|
|
|
|
|
|
|
_location._animations.remove(_char._ani);
|
|
|
|
|
2008-02-03 10:48:07 +00:00
|
|
|
freeZones();
|
2008-02-03 11:00:55 +00:00
|
|
|
freeAnimations();
|
2008-07-11 13:06:28 +00:00
|
|
|
|
|
|
|
_location._animations.push_front(_char._ani);
|
|
|
|
|
2008-08-21 12:11:24 +00:00
|
|
|
free(_location._comment);
|
|
|
|
_location._comment = 0;
|
2008-07-25 08:27:44 +00:00
|
|
|
_location._commands.clear();
|
|
|
|
_location._aCommands.clear();
|
2008-02-02 21:22:05 +00:00
|
|
|
|
2008-08-21 12:11:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Parallaction_br::changeLocation(char *location) {
|
2008-08-31 05:18:25 +00:00
|
|
|
char *partStr = strrchr(location, '.');
|
|
|
|
if (partStr) {
|
|
|
|
int n = partStr - location;
|
|
|
|
strncpy(_location._name, location, n);
|
|
|
|
_location._name[n] = '\0';
|
|
|
|
|
|
|
|
_part = atoi(++partStr);
|
|
|
|
if (getFeatures() & GF_DEMO) {
|
|
|
|
assert(_part == 1);
|
|
|
|
} else {
|
|
|
|
assert(_part >= 0 && _part <= 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
_disk->selectArchive(_partNames[_part]);
|
|
|
|
initPart();
|
|
|
|
parseLocation("common");
|
|
|
|
}
|
|
|
|
|
2008-08-21 12:11:24 +00:00
|
|
|
freeLocation();
|
2008-02-02 22:45:31 +00:00
|
|
|
// load new location
|
|
|
|
parseLocation(location);
|
2008-08-21 12:11:24 +00:00
|
|
|
// kFlagsRemove is cleared because the character is visible by default.
|
|
|
|
// Commands can hide the character, anyway.
|
2008-07-25 08:27:44 +00:00
|
|
|
_char._ani->_flags &= ~kFlagsRemove;
|
2008-07-11 13:06:28 +00:00
|
|
|
_cmdExec->run(_location._commands);
|
2008-08-21 12:11:24 +00:00
|
|
|
|
|
|
|
doLocationEnterTransition();
|
|
|
|
|
2008-07-11 13:06:28 +00:00
|
|
|
_cmdExec->run(_location._aCommands);
|
2008-02-02 21:22:05 +00:00
|
|
|
|
2008-02-02 22:45:31 +00:00
|
|
|
_engineFlags &= ~kEngineChangeLocation;
|
2007-08-25 20:34:10 +00:00
|
|
|
}
|
|
|
|
|
2008-05-09 01:35:43 +00:00
|
|
|
// FIXME: Parallaction_br::parseLocation() is now a verbatim copy of the same routine from Parallaction_ns.
|
|
|
|
void Parallaction_br::parseLocation(const char *filename) {
|
|
|
|
debugC(1, kDebugParser, "parseLocation('%s')", filename);
|
|
|
|
|
|
|
|
allocateLocationSlot(filename);
|
|
|
|
Script *script = _disk->loadLocation(filename);
|
|
|
|
|
|
|
|
_locationParser->parse(script);
|
|
|
|
delete script;
|
|
|
|
|
|
|
|
// this loads animation scripts
|
|
|
|
AnimationList::iterator it = _vm->_location._animations.begin();
|
|
|
|
for ( ; it != _vm->_location._animations.end(); it++) {
|
|
|
|
if ((*it)->_scriptName) {
|
|
|
|
loadProgram(*it, (*it)->_scriptName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
debugC(1, kDebugParser, "parseLocation('%s') done", filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-03 00:49:27 +00:00
|
|
|
void Parallaction_br::loadProgram(AnimationPtr a, const char *filename) {
|
|
|
|
debugC(1, kDebugParser, "loadProgram(Animation: %s, script: %s)", a->_name, filename);
|
|
|
|
|
|
|
|
Script *script = _disk->loadScript(filename);
|
|
|
|
ProgramPtr program(new Program);
|
|
|
|
program->_anim = a;
|
|
|
|
|
|
|
|
_programParser->parse(script, program);
|
|
|
|
|
|
|
|
delete script;
|
|
|
|
|
|
|
|
_vm->_location._programs.push_back(program);
|
|
|
|
|
|
|
|
debugC(1, kDebugParser, "loadProgram() done");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 01:35:43 +00:00
|
|
|
|
2007-08-25 20:34:10 +00:00
|
|
|
void Parallaction_br::changeCharacter(const char *name) {
|
2008-06-04 09:07:55 +00:00
|
|
|
const char *charName = _char.getName();
|
2008-07-25 08:27:44 +00:00
|
|
|
|
|
|
|
if (scumm_stricmp(charName, name)) {
|
|
|
|
debugC(1, kDebugExec, "changeCharacter(%s)", name);
|
|
|
|
|
|
|
|
_char.setName(name);
|
|
|
|
_char._ani->gfxobj = _gfx->loadAnim(name);
|
|
|
|
_char._ani->gfxobj->setFlags(kGfxObjCharacter);
|
|
|
|
_char._ani->gfxobj->clearFlags(kGfxObjNormal);
|
|
|
|
_char._talk = _disk->loadTalk(name);
|
2008-06-04 09:07:55 +00:00
|
|
|
}
|
2007-08-25 20:34:10 +00:00
|
|
|
|
2008-07-25 08:27:44 +00:00
|
|
|
_char._ani->_flags |= kFlagsActive;
|
2007-08-25 20:34:10 +00:00
|
|
|
}
|
|
|
|
|
2007-09-23 20:17:50 +00:00
|
|
|
|
|
|
|
|
2007-07-29 14:24:31 +00:00
|
|
|
} // namespace Parallaction
|