2007-01-14 21:29:12 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2006 The ScummVM project
|
|
|
|
*
|
|
|
|
* 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-02-21 21:42:37 +00:00
|
|
|
#include "common/stdafx.h"
|
|
|
|
|
|
|
|
#include "common/config-manager.h"
|
2007-03-17 00:53:21 +00:00
|
|
|
#include "common/events.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/util.h"
|
2007-02-21 21:42:37 +00:00
|
|
|
|
|
|
|
#include "sound/mididrv.h"
|
|
|
|
#include "sound/mixer.h"
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
#include "parallaction/parallaction.h"
|
|
|
|
#include "parallaction/menu.h"
|
2007-02-19 13:07:18 +00:00
|
|
|
#include "parallaction/parser.h"
|
2007-01-14 21:29:12 +00:00
|
|
|
#include "parallaction/disk.h"
|
|
|
|
#include "parallaction/music.h"
|
|
|
|
#include "parallaction/inventory.h"
|
|
|
|
#include "parallaction/graphics.h"
|
2007-03-12 22:52:27 +00:00
|
|
|
#include "parallaction/walk.h"
|
2007-01-14 21:29:12 +00:00
|
|
|
#include "parallaction/zone.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Parallaction {
|
|
|
|
|
|
|
|
// FIXME: remove this
|
|
|
|
Parallaction *_vm = NULL;
|
|
|
|
|
|
|
|
// public stuff
|
|
|
|
Point _mousePos = { 0, 0 };
|
|
|
|
uint16 _mouseButtons = 0;
|
|
|
|
|
|
|
|
|
|
|
|
char _saveData1[30] = { '\0' };
|
|
|
|
uint16 _language = 0;
|
2007-03-11 14:14:08 +00:00
|
|
|
char _slideText[2][40];
|
2007-01-14 21:29:12 +00:00
|
|
|
uint32 _engineFlags = 0;
|
|
|
|
char *_objectsNames[100];
|
|
|
|
Zone *_activeZone = NULL;
|
2007-03-11 00:04:50 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
uint16 _score = 1;
|
2007-03-11 14:14:08 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
uint32 _localFlags[120] = { 0 };
|
|
|
|
|
2007-01-15 21:14:34 +00:00
|
|
|
static char tmp_visited_str[] = "visited";
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
char *_localFlagNames[32] = {
|
2007-01-15 21:14:34 +00:00
|
|
|
tmp_visited_str, // "visited",
|
2007-01-14 21:29:12 +00:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
Command * _forwardedCommands[20] = {
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
char _forwardedAnimationNames[20][20];
|
|
|
|
uint16 _numForwards = 0;
|
|
|
|
char _soundFile[20];
|
2007-03-11 13:01:11 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
char *_globalTable[32];
|
2007-03-11 14:14:08 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
byte _mouseHidden = 0;
|
2007-03-11 14:14:08 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
uint32 _commandFlags = 0;
|
|
|
|
uint16 _introSarcData3 = 200;
|
|
|
|
uint16 _introSarcData2 = 1;
|
|
|
|
|
|
|
|
// private stuff
|
|
|
|
|
|
|
|
static Job *_jDrawInventory = NULL;
|
2007-02-04 15:48:51 +00:00
|
|
|
Job *_jDrawLabel = NULL;
|
|
|
|
Job *_jEraseLabel = NULL;
|
2007-02-04 08:12:33 +00:00
|
|
|
Zone *_hoverZone = NULL;
|
2007-01-14 21:29:12 +00:00
|
|
|
static Job *_jRunScripts = NULL;
|
|
|
|
|
2007-03-11 00:04:50 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
Parallaction::Parallaction(OSystem *syst) :
|
|
|
|
Engine(syst) {
|
|
|
|
|
|
|
|
// FIXME
|
|
|
|
_vm = this;
|
2007-03-04 13:27:29 +00:00
|
|
|
_disk = new Disk(this);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
_skipMenu = false;
|
|
|
|
|
|
|
|
_transCurrentHoverItem = 0;
|
|
|
|
_actionAfterWalk = false; // actived when the character needs to move before taking an action
|
|
|
|
_activeItem._index = 0;
|
|
|
|
_activeItem._id = 0;
|
|
|
|
_procCurrentHoverItem = -1;
|
|
|
|
|
2007-02-20 09:17:28 +00:00
|
|
|
_locationScript = NULL;
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
_musicData1 = 0;
|
|
|
|
strcpy(_characterName1, "null");
|
|
|
|
|
2007-02-21 21:42:37 +00:00
|
|
|
_midiPlayer = 0;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
_baseTime = 0;
|
|
|
|
|
|
|
|
Common::File::addDefaultDirectory( _gameDataPath );
|
|
|
|
|
2007-02-17 15:37:49 +00:00
|
|
|
Common::addSpecialDebugLevel(kDebugDialogue, "dialogue", "Dialogues debug level");
|
|
|
|
Common::addSpecialDebugLevel(kDebugLocation, "location", "Location debug level");
|
2007-01-26 23:24:12 +00:00
|
|
|
Common::addSpecialDebugLevel(kDebugDisk, "disk", "Disk debug level");
|
|
|
|
Common::addSpecialDebugLevel(kDebugWalk, "walk", "Walk debug level");
|
2007-02-04 15:43:45 +00:00
|
|
|
Common::addSpecialDebugLevel(kDebugGraphics, "gfx", "Gfx debug level");
|
2007-02-18 09:33:53 +00:00
|
|
|
Common::addSpecialDebugLevel(kDebugJobs, "jobs", "Jobs debug level");
|
|
|
|
Common::addSpecialDebugLevel(kDebugInput, "input", "Input debug level");
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Parallaction::~Parallaction() {
|
2007-02-21 21:42:37 +00:00
|
|
|
delete _midiPlayer;
|
2007-03-04 13:27:29 +00:00
|
|
|
delete _disk;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Parallaction::init() {
|
|
|
|
|
|
|
|
// Detect game
|
|
|
|
if (!detectGame()) {
|
|
|
|
GUIErrorMessage("No valid games were found in the specified directory.");
|
|
|
|
return -1;
|
|
|
|
}
|
2007-02-17 15:37:49 +00:00
|
|
|
|
2007-03-11 15:10:45 +00:00
|
|
|
_engineFlags = 0;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-11 15:10:45 +00:00
|
|
|
strcpy(_characterName, "dough");
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-02-17 15:37:49 +00:00
|
|
|
memset(_locationNames, 0, 120*32);
|
2007-01-26 23:24:12 +00:00
|
|
|
_numLocations = 0;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-11 14:14:08 +00:00
|
|
|
_location._startPosition._x = -1000;
|
|
|
|
_location._startPosition._x = -1000;
|
|
|
|
_location._startFrame = 0;
|
|
|
|
_location._walkNodes._prev = NULL;
|
|
|
|
_location._walkNodes._next = NULL;
|
|
|
|
strcpy(_location._name, "fogne");
|
|
|
|
_location._aCommands = NULL;
|
|
|
|
_location._commands = NULL;
|
|
|
|
_location._comment = NULL;
|
|
|
|
_location._endComment = NULL;
|
|
|
|
|
2007-03-12 22:52:27 +00:00
|
|
|
initWalk();
|
2007-03-11 14:14:08 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
initInventory();
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
addNode(&_animations, &_vm->_char._ani._zone);
|
2007-03-12 20:41:25 +00:00
|
|
|
_gfx = new Gfx(this);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-02-21 21:42:37 +00:00
|
|
|
int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
|
|
|
|
MidiDriver *driver = MidiDriver::createMidi(midiDriver);
|
|
|
|
_midiPlayer = new MidiPlayer(driver);
|
|
|
|
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Parallaction::go() {
|
|
|
|
|
|
|
|
initGame();
|
|
|
|
runGame();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::initGame() {
|
|
|
|
|
|
|
|
_menu = new Menu(this);
|
|
|
|
|
|
|
|
initGlobals();
|
|
|
|
if (_skipMenu == false) {
|
|
|
|
_menu->start();
|
|
|
|
}
|
|
|
|
|
2007-03-11 14:14:08 +00:00
|
|
|
char *v4 = strchr(_location._name, '.');
|
2007-01-14 21:29:12 +00:00
|
|
|
if (v4) {
|
|
|
|
*v4 = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
_engineFlags &= ~kEngineChangeLocation;
|
|
|
|
changeCharacter(_characterName);
|
|
|
|
|
2007-03-11 14:14:08 +00:00
|
|
|
strcpy(_saveData1, _location._name);
|
|
|
|
parseLocation(_location._name);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-11 14:14:08 +00:00
|
|
|
if (_location._startPosition._x != -1000) {
|
2007-03-17 07:55:16 +00:00
|
|
|
_vm->_char._ani._zone.pos._position._x = _location._startPosition._x;
|
|
|
|
_vm->_char._ani._zone.pos._position._y = _location._startPosition._y;
|
|
|
|
_vm->_char._ani._frame = _location._startFrame;
|
2007-03-11 14:14:08 +00:00
|
|
|
_location._startPosition._y = -1000;
|
|
|
|
_location._startPosition._x = -1000;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::initGlobals() {
|
|
|
|
|
|
|
|
initTable("global.tab", _globalTable);
|
|
|
|
}
|
|
|
|
|
2007-02-17 15:57:49 +00:00
|
|
|
// FIXME: the engine has 3 event loops. The following routine hosts the main one,
|
|
|
|
// and it's called from 8 different places in the code. There exist 2 more specialised
|
|
|
|
// loops which could possibly be merged into this one with some effort in changing
|
|
|
|
// caller code, i.e. adding condition checks.
|
2007-01-14 21:29:12 +00:00
|
|
|
//
|
|
|
|
uint16 Parallaction::updateInput() {
|
|
|
|
|
|
|
|
OSystem::Event e;
|
|
|
|
uint16 KeyDown = 0;
|
|
|
|
|
|
|
|
_mouseButtons = kMouseNone;
|
|
|
|
|
2007-03-17 00:53:21 +00:00
|
|
|
Common::EventManager *eventMan = _system->getEventManager();
|
|
|
|
while (eventMan->pollEvent(e)) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
switch (e.type) {
|
|
|
|
case OSystem::EVENT_KEYDOWN:
|
|
|
|
if (e.kbd.ascii == 'l') KeyDown = kEvLoadGame;
|
|
|
|
if (e.kbd.ascii == 's') KeyDown = kEvSaveGame;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_LBUTTONDOWN:
|
|
|
|
_mouseButtons = kMouseLeftDown;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_LBUTTONUP:
|
|
|
|
_mouseButtons = kMouseLeftUp;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_RBUTTONDOWN:
|
|
|
|
_mouseButtons = kMouseRightDown;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_RBUTTONUP:
|
|
|
|
_mouseButtons = kMouseRightUp;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_MOUSEMOVE:
|
|
|
|
_mousePos._x = e.mouse.x;
|
|
|
|
_mousePos._y = e.mouse.y;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OSystem::EVENT_QUIT:
|
2007-02-17 16:06:34 +00:00
|
|
|
_system->quit();
|
2007-01-14 21:29:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return KeyDown;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-02-17 15:57:49 +00:00
|
|
|
// FIXME: see comment for updateInput()
|
2007-01-14 21:29:12 +00:00
|
|
|
void waitUntilLeftClick() {
|
|
|
|
|
|
|
|
OSystem::Event e;
|
|
|
|
|
2007-03-17 00:53:21 +00:00
|
|
|
Common::EventManager *eventMan = g_system->getEventManager();
|
2007-01-14 21:29:12 +00:00
|
|
|
for (;;) {
|
2007-03-17 00:53:21 +00:00
|
|
|
eventMan->pollEvent(e);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-02-17 16:06:34 +00:00
|
|
|
if (e.type == OSystem::EVENT_LBUTTONUP)
|
|
|
|
break;
|
2007-02-17 15:57:49 +00:00
|
|
|
|
2007-02-17 16:06:34 +00:00
|
|
|
if (e.type == OSystem::EVENT_QUIT) {
|
|
|
|
g_system->quit();
|
|
|
|
break;
|
|
|
|
}
|
2007-02-17 15:57:49 +00:00
|
|
|
|
|
|
|
g_system->delayMillis(10);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Parallaction::runGame() {
|
|
|
|
|
2007-02-04 08:12:33 +00:00
|
|
|
addJob(jobEraseAnimations, (void*)1, kPriority20);
|
|
|
|
_jRunScripts = addJob(jobRunScripts, 0, kPriority15);
|
|
|
|
addJob(jobDisplayAnimations, 0, kPriority3);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
_gfx->copyScreen(Gfx::kBitBack, Gfx::kBit2);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-11 14:14:08 +00:00
|
|
|
if (_location._commands)
|
|
|
|
runCommands(_location._commands);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
runJobs();
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-11 14:14:08 +00:00
|
|
|
if (_location._comment)
|
2007-01-14 21:29:12 +00:00
|
|
|
doLocationEnterTransition();
|
|
|
|
|
|
|
|
changeCursor(kCursorArrow);
|
|
|
|
|
2007-03-11 14:14:08 +00:00
|
|
|
if (_location._aCommands)
|
|
|
|
runCommands(_location._aCommands);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
while ((_engineFlags & kEngineQuit) == 0) {
|
|
|
|
_keyDown = updateInput();
|
|
|
|
|
2007-02-18 10:31:29 +00:00
|
|
|
debugC(3, kDebugInput, "runGame: input flags (%i, %i, %i, %i)",
|
2007-02-17 15:37:49 +00:00
|
|
|
_mouseHidden == 0,
|
|
|
|
(_engineFlags & kEngineMouse) == 0,
|
|
|
|
(_engineFlags & kEngineWalking) == 0,
|
|
|
|
(_engineFlags & kEngineChangeLocation) == 0
|
|
|
|
);
|
|
|
|
|
|
|
|
// WORKAROUND: the engine doesn't check for displayed labels before performing a location
|
|
|
|
// switch, thus crashing whenever a jobDisplayLabel/jEraseLabel pair is left into the
|
|
|
|
// queue after the character enters a door.
|
|
|
|
// Skipping input processing when kEngineChangeLocation is set solves the issue. It's
|
|
|
|
// noteworthy that the programmers added this very check in Big Red Adventure's engine,
|
|
|
|
// so it should be ok here in Nippon Safes too.
|
2007-02-04 11:16:40 +00:00
|
|
|
if ((_mouseHidden == 0) && ((_engineFlags & kEngineMouse) == 0) && ((_engineFlags & kEngineWalking) == 0) && ((_engineFlags & kEngineChangeLocation) == 0)) {
|
2007-01-14 21:29:12 +00:00
|
|
|
InputData *v8 = translateInput();
|
|
|
|
if (v8) processInput(v8);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_activeZone) {
|
|
|
|
Zone *z = _activeZone; // speak Zone or sound
|
|
|
|
_activeZone = NULL;
|
|
|
|
if (runZone( z ) == 0)
|
|
|
|
runCommands( z->_commands, z );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_engineFlags & kEngineChangeLocation) {
|
|
|
|
_engineFlags &= ~kEngineChangeLocation;
|
2007-03-11 14:14:08 +00:00
|
|
|
changeLocation(_location._name);
|
2007-01-14 21:29:12 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_system->delayMillis(30);
|
|
|
|
|
|
|
|
runJobs();
|
|
|
|
|
|
|
|
if ((_engineFlags & kEnginePauseJobs) == 0 || (_engineFlags & kEngineInventory)) {
|
2007-03-12 20:41:25 +00:00
|
|
|
_gfx->swapBuffers();
|
2007-01-14 21:29:12 +00:00
|
|
|
byte palette[PALETTE_SIZE];
|
2007-03-15 21:56:21 +00:00
|
|
|
memcpy(palette, _vm->_gfx->_palette, sizeof(palette));
|
2007-03-12 20:41:25 +00:00
|
|
|
_gfx->animatePalette(palette);
|
|
|
|
_gfx->setPalette(palette);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
delete _menu;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Parallaction::processInput(InputData *data) {
|
|
|
|
Zone *z;
|
|
|
|
WalkNode *v4;
|
|
|
|
|
|
|
|
switch (data->_event) {
|
|
|
|
case kEvEnterZone:
|
2007-02-18 09:33:53 +00:00
|
|
|
debugC(2, kDebugInput, "processInput: kEvEnterZone");
|
2007-03-12 20:41:25 +00:00
|
|
|
_gfx->_labelPosition[1]._x = -1000;
|
|
|
|
_gfx->_labelPosition[1]._y = -1000;
|
|
|
|
_gfx->_labelPosition[0]._x = -1000;
|
|
|
|
_gfx->_labelPosition[0]._y = -1000;
|
2007-02-04 08:12:33 +00:00
|
|
|
_jDrawLabel = addJob(&jobDisplayLabel, (void*)data->_label, kPriority0);
|
|
|
|
_jEraseLabel = addJob(&jobEraseLabel, (void*)data->_label, kPriority20);
|
2007-01-14 21:29:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvExitZone:
|
2007-02-18 09:33:53 +00:00
|
|
|
debugC(2, kDebugInput, "processInput: kEvExitZone");
|
2007-01-14 21:29:12 +00:00
|
|
|
removeJob(_jDrawLabel);
|
2007-02-04 08:12:33 +00:00
|
|
|
addJob(&jobWaitRemoveJob, _jEraseLabel, kPriority15);
|
2007-01-14 21:29:12 +00:00
|
|
|
_jDrawLabel = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvAction:
|
2007-02-18 09:33:53 +00:00
|
|
|
debugC(2, kDebugInput, "processInput: kEvAction");
|
2007-01-14 21:29:12 +00:00
|
|
|
_procCurrentHoverItem = -1;
|
|
|
|
_hoverZone = NULL;
|
|
|
|
pauseJobs();
|
2007-01-15 20:11:49 +00:00
|
|
|
z = data->_zone;
|
2007-01-14 21:29:12 +00:00
|
|
|
if (runZone(z) == 0) {
|
|
|
|
runCommands( z->_commands, z );
|
|
|
|
}
|
|
|
|
resumeJobs();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvOpenInventory:
|
|
|
|
_procCurrentHoverItem = -1;
|
2007-02-04 08:12:33 +00:00
|
|
|
_hoverZone = NULL;
|
2007-01-14 21:29:12 +00:00
|
|
|
if (_jDrawLabel != 0) {
|
|
|
|
removeJob(_jDrawLabel);
|
|
|
|
_jDrawLabel = NULL;
|
2007-02-04 08:12:33 +00:00
|
|
|
addJob(&jobWaitRemoveJob, _jEraseLabel, kPriority2);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
if (hitZone(kZoneYou, _mousePos._x, _mousePos._y) == 0)
|
|
|
|
changeCursor(kCursorArrow);
|
|
|
|
removeJob(_jRunScripts);
|
2007-02-04 08:12:33 +00:00
|
|
|
_jDrawInventory = addJob(&jobShowInventory, 0, kPriority2);
|
2007-01-14 21:29:12 +00:00
|
|
|
openInventory();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvCloseInventory: // closes inventory and possibly select item
|
|
|
|
closeInventory();
|
2007-01-15 20:11:49 +00:00
|
|
|
if ((data->_inventoryIndex != -1) && (_inventory[data->_inventoryIndex]._id != 0)) {
|
2007-01-14 21:29:12 +00:00
|
|
|
// activates item
|
2007-01-15 20:11:49 +00:00
|
|
|
changeCursor(data->_inventoryIndex);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
2007-02-04 08:12:33 +00:00
|
|
|
_jRunScripts = addJob(&jobRunScripts, 0, kPriority15);
|
|
|
|
addJob(&jobHideInventory, 0, kPriority20);
|
2007-01-14 21:29:12 +00:00
|
|
|
removeJob(_jDrawInventory);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvHoverInventory:
|
|
|
|
highlightInventoryItem(_procCurrentHoverItem, 12); // disable
|
2007-01-15 20:11:49 +00:00
|
|
|
highlightInventoryItem(data->_inventoryIndex, 19); // enable
|
|
|
|
_procCurrentHoverItem = data->_inventoryIndex;
|
2007-01-14 21:29:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvWalk:
|
2007-02-18 09:33:53 +00:00
|
|
|
debugC(2, kDebugInput, "processInput: kEvWalk");
|
2007-02-04 08:12:33 +00:00
|
|
|
_hoverZone = NULL;
|
2007-01-14 21:29:12 +00:00
|
|
|
changeCursor(kCursorArrow);
|
2007-03-17 07:55:16 +00:00
|
|
|
if (_vm->_char._ani._zone._flags & kFlagsRemove) break;
|
|
|
|
if ((_vm->_char._ani._zone._flags & kFlagsActive) == 0) break;
|
2007-01-14 21:29:12 +00:00
|
|
|
v4 = buildWalkPath(data->_mousePos._x, data->_mousePos._y);
|
2007-02-04 08:12:33 +00:00
|
|
|
addJob(jobWalk, v4, kPriority19);
|
2007-01-14 21:29:12 +00:00
|
|
|
_engineFlags |= kEngineWalking; // inhibits processing of input until walking is over
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvQuitGame:
|
|
|
|
_engineFlags |= kEngineQuit;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvSaveGame:
|
|
|
|
_hoverZone = NULL;
|
|
|
|
changeCursor(kCursorArrow);
|
|
|
|
saveGame();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvLoadGame:
|
|
|
|
_hoverZone = NULL;
|
|
|
|
changeCursor(kCursorArrow);
|
|
|
|
loadGame();
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Parallaction::InputData *Parallaction::translateInput() {
|
|
|
|
|
|
|
|
if (_keyDown == kEvQuitGame) {
|
|
|
|
_input._event = kEvQuitGame;
|
|
|
|
return &_input;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_keyDown == kEvSaveGame) {
|
|
|
|
_input._event = kEvSaveGame;
|
|
|
|
return &_input;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_keyDown == kEvLoadGame) {
|
|
|
|
_input._event = kEvLoadGame;
|
|
|
|
return &_input;
|
|
|
|
}
|
|
|
|
|
|
|
|
_input._mousePos._x = _mousePos._x;
|
|
|
|
_input._mousePos._y = _mousePos._y;
|
|
|
|
|
|
|
|
if (((_engineFlags & kEnginePauseJobs) == 0) && ((_engineFlags & kEngineInventory) == 0)) {
|
|
|
|
|
|
|
|
if (_actionAfterWalk == true) {
|
|
|
|
// if walking is over, then take programmed action
|
|
|
|
_input._event = kEvAction;
|
|
|
|
_actionAfterWalk = false;
|
|
|
|
return &_input;
|
|
|
|
}
|
|
|
|
|
|
|
|
Zone *z = hitZone(_activeItem._id, _mousePos._x, _mousePos._y);
|
|
|
|
|
|
|
|
if (_mouseButtons == kMouseRightDown) {
|
|
|
|
// right button down shows inventory
|
|
|
|
|
|
|
|
if (hitZone(kZoneYou, _mousePos._x, _mousePos._y) && (_activeItem._id != 0)) {
|
|
|
|
_activeItem._index = (_activeItem._id >> 16) & 0xFFFF;
|
|
|
|
_engineFlags |= kEngineDragging;
|
|
|
|
}
|
|
|
|
|
|
|
|
_input._event = kEvOpenInventory;
|
|
|
|
_transCurrentHoverItem = -1;
|
|
|
|
return &_input;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((z == NULL) || ((z->_type & 0xFFFF) != kZoneCommand))) {
|
|
|
|
_input._event = kEvWalk;
|
|
|
|
return &_input;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((z != _hoverZone) && (_hoverZone != NULL)) {
|
|
|
|
_hoverZone = NULL;
|
|
|
|
_input._event = kEvExitZone;
|
|
|
|
// _input._data= &z->_name;
|
|
|
|
return &_input;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (z == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((_hoverZone == NULL) && ((z->_flags & kFlagsNoName) == 0)) {
|
|
|
|
_hoverZone = z;
|
|
|
|
_input._event = kEvEnterZone;
|
2007-02-04 08:12:33 +00:00
|
|
|
_input._label = &z->_label;
|
2007-01-14 21:29:12 +00:00
|
|
|
return &_input;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((_mouseButtons == kMouseLeftUp) && ((_activeItem._id != 0) || ((z->_type & 0xFFFF) == kZoneCommand))) {
|
|
|
|
|
2007-01-15 20:11:49 +00:00
|
|
|
_input._zone = z;
|
2007-01-14 21:29:12 +00:00
|
|
|
if (z->_flags & kFlagsNoWalk) {
|
|
|
|
// character doesn't need to walk to take specified action
|
|
|
|
_input._event = kEvAction;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// action delayed: if Zone defined a moveto position the character is programmed to move there,
|
|
|
|
// else it will move to the mouse position
|
|
|
|
_input._event = kEvWalk;
|
|
|
|
_actionAfterWalk = true;
|
|
|
|
if (z->_moveTo._y != 0) {
|
|
|
|
_input._mousePos._x = z->_moveTo._x;
|
|
|
|
_input._mousePos._y = z->_moveTo._y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
beep();
|
|
|
|
changeCursor(kCursorArrow);
|
|
|
|
return &_input;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((_engineFlags & kEngineInventory) == 0) return NULL;
|
|
|
|
|
|
|
|
// in inventory
|
|
|
|
int16 _si = getHoverInventoryItem(_mousePos._x, _mousePos._y);
|
|
|
|
|
|
|
|
if (_mouseButtons == kMouseRightUp) {
|
|
|
|
// right up hides inventory
|
|
|
|
|
|
|
|
_input._event = kEvCloseInventory;
|
2007-01-15 20:11:49 +00:00
|
|
|
_input._inventoryIndex = getHoverInventoryItem(_mousePos._x, _mousePos._y);
|
2007-01-14 21:29:12 +00:00
|
|
|
highlightInventoryItem(_transCurrentHoverItem, 12); // disable
|
|
|
|
|
|
|
|
if ((_engineFlags & kEngineDragging) == 0) return &_input;
|
|
|
|
|
|
|
|
_engineFlags &= ~kEngineDragging;
|
2007-01-15 20:11:49 +00:00
|
|
|
Zone *z = hitZone(kZoneMerge, _activeItem._index, _inventory[_input._inventoryIndex]._index);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
if (z != NULL) {
|
|
|
|
dropItem(z->u.merge->_obj1 - 4);
|
|
|
|
dropItem(z->u.merge->_obj2 - 4);
|
|
|
|
addInventoryItem(z->u.merge->_obj3);
|
|
|
|
runCommands(z->_commands);
|
|
|
|
}
|
|
|
|
|
|
|
|
return &_input;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_si == _transCurrentHoverItem) return NULL;
|
|
|
|
|
|
|
|
_transCurrentHoverItem = _si;
|
|
|
|
_input._event = kEvHoverInventory;
|
2007-01-15 20:11:49 +00:00
|
|
|
_input._inventoryIndex = _si;
|
2007-01-14 21:29:12 +00:00
|
|
|
return &_input;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 Parallaction::getElapsedTime() {
|
|
|
|
return g_system->getMillis() - _baseTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::resetTimer() {
|
|
|
|
_baseTime = g_system->getMillis();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Parallaction::waitTime(uint32 t) {
|
|
|
|
|
|
|
|
uint32 v4 = 0;
|
|
|
|
|
|
|
|
while (v4 < t * (1000 / 18.2)) {
|
|
|
|
v4 = getElapsedTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
resetTimer();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// changes the mouse pointer
|
|
|
|
// index 0 means standard pointer (from pointer.cnv)
|
|
|
|
// index > 0 means inventory item
|
|
|
|
//
|
|
|
|
void Parallaction::changeCursor(int32 index) {
|
|
|
|
|
|
|
|
if (index == kCursorArrow) { // standard mouse pointer
|
|
|
|
|
2007-02-18 09:33:53 +00:00
|
|
|
debugC(1, kDebugInput, "changeCursor(%i), label: %p", index, (const void*)_jDrawLabel);
|
2007-02-04 08:12:33 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
if (_jDrawLabel != NULL) {
|
|
|
|
removeJob(_jDrawLabel);
|
2007-02-04 08:12:33 +00:00
|
|
|
addJob(&jobWaitRemoveJob, _jEraseLabel, kPriority15 );
|
2007-01-14 21:29:12 +00:00
|
|
|
_jDrawLabel = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
_activeItem._id = 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
_activeItem._id = _inventory[index]._id;
|
|
|
|
}
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
_gfx->setMousePointer(index);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-03-17 07:56:45 +00:00
|
|
|
void freeCharacter() {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-17 07:55:16 +00:00
|
|
|
_vm->_gfx->freeCnv(&_vm->_char._normalFrames);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-10 22:55:09 +00:00
|
|
|
if (!IS_DUMMY_CHARACTER(_vm->_characterName)) {
|
2007-03-17 07:55:16 +00:00
|
|
|
_vm->_gfx->freeCnv(&_vm->_char._miniFrames);
|
2007-01-14 21:29:12 +00:00
|
|
|
_vm->freeTable(_objectsNames);
|
2007-03-17 07:55:16 +00:00
|
|
|
_vm->_gfx->freeCnv(&_vm->_char._talk);
|
|
|
|
_vm->_gfx->freeStaticCnv(&_vm->_char._head);
|
|
|
|
_vm->_gfx->freeCnv(&_vm->_char._objs);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-10 22:13:47 +00:00
|
|
|
void Parallaction::selectCharacterMusic(const char *name) {
|
2007-03-10 22:55:09 +00:00
|
|
|
if (IS_MINI_CHARACTER(name))
|
2007-03-10 22:13:47 +00:00
|
|
|
name+=4;
|
|
|
|
|
|
|
|
if (!scumm_stricmp(name, _dinoName)) {
|
|
|
|
_midiPlayer->play("dino");
|
|
|
|
} else if (!scumm_stricmp(name, _donnaName)) {
|
|
|
|
_midiPlayer->play("donna");
|
|
|
|
} else {
|
|
|
|
_midiPlayer->play("nuts");
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-10 22:13:47 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-11 10:50:52 +00:00
|
|
|
void Parallaction::pickMusic(const char *location) {
|
|
|
|
if (_musicData1 != 0) {
|
|
|
|
selectCharacterMusic(_vm->_characterName);
|
|
|
|
_musicData1 = 0;
|
|
|
|
debugC(2, kDebugLocation, "changeLocation: started character specific music");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!scumm_stricmp(location, "night") || !scumm_stricmp(location, "intsushi")) {
|
|
|
|
_vm->_midiPlayer->play("soft");
|
|
|
|
|
|
|
|
debugC(2, kDebugLocation, "changeLocation: started music 'soft'");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!scumm_stricmp(location, "museo") ||
|
|
|
|
!scumm_stricmp(location, "caveau") ||
|
|
|
|
!scumm_strnicmp(location, "plaza1", 6) ||
|
|
|
|
!scumm_stricmp(location, "estgrotta") ||
|
|
|
|
!scumm_stricmp(location, "intgrottadopo") ||
|
|
|
|
!scumm_stricmp(location, "endtgz") ||
|
|
|
|
!scumm_stricmp(location, "common")) {
|
|
|
|
|
|
|
|
_vm->_midiPlayer->stop();
|
|
|
|
_musicData1 = 1;
|
|
|
|
|
|
|
|
debugC(2, kDebugLocation, "changeLocation: music stopped");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
void Parallaction::changeCharacter(const char *name) {
|
|
|
|
|
2007-03-10 22:13:47 +00:00
|
|
|
bool miniCharacter = false;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-10 22:55:09 +00:00
|
|
|
if (IS_MINI_CHARACTER(name)) {
|
2007-01-14 21:29:12 +00:00
|
|
|
name+=4;
|
2007-03-10 22:13:47 +00:00
|
|
|
miniCharacter = true;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char v32[20];
|
|
|
|
strcpy(v32, name);
|
|
|
|
|
2007-03-11 00:04:50 +00:00
|
|
|
if (_engineFlags & kEngineTransformedDonna)
|
2007-01-14 21:29:12 +00:00
|
|
|
strcat(v32, "tras");
|
|
|
|
|
|
|
|
if (scumm_stricmp(v32, _characterName1)) {
|
|
|
|
|
2007-03-11 00:04:50 +00:00
|
|
|
if (scumm_stricmp(_characterName1, "null"))
|
2007-03-17 07:56:45 +00:00
|
|
|
freeCharacter();
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-04 13:27:29 +00:00
|
|
|
_disk->selectArchive("disk1");
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
char path[PATH_LEN];
|
|
|
|
strcpy(path, v32);
|
2007-03-17 07:55:16 +00:00
|
|
|
_disk->loadFrames(path, &_vm->_char._normalFrames);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-10 22:55:09 +00:00
|
|
|
if (!IS_DUMMY_CHARACTER(name)) {
|
2007-03-17 07:55:16 +00:00
|
|
|
_disk->loadHead(path, &_vm->_char._head);
|
|
|
|
_disk->loadTalk(path, &_vm->_char._talk);
|
|
|
|
_disk->loadObjects(name, &_vm->_char._objs);
|
2007-03-10 14:52:33 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
sprintf(path, "mini%s", v32);
|
2007-03-17 07:55:16 +00:00
|
|
|
_disk->loadFrames(path, &_vm->_char._miniFrames);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
sprintf(path, "%s.tab", name);
|
|
|
|
initTable(path, _objectsNames);
|
|
|
|
|
|
|
|
refreshInventory(name);
|
|
|
|
|
2007-03-10 22:13:47 +00:00
|
|
|
if (scumm_stricmp(name, "night") && scumm_stricmp(name, "intsushi"))
|
|
|
|
selectCharacterMusic(name);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-11 00:04:50 +00:00
|
|
|
if (miniCharacter)
|
2007-03-17 07:55:16 +00:00
|
|
|
memcpy(&_vm->_char._ani._cnv, &_vm->_char._miniFrames, sizeof(Cnv));
|
2007-03-11 00:04:50 +00:00
|
|
|
else
|
2007-03-17 07:55:16 +00:00
|
|
|
memcpy(&_vm->_char._ani._cnv, &_vm->_char._normalFrames, sizeof(Cnv));
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
strcpy(_characterName1, v32);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void freeNodeList(Node *list) {
|
|
|
|
|
|
|
|
while (list) {
|
|
|
|
Node *v4 = list->_next;
|
2007-03-04 08:58:23 +00:00
|
|
|
free(list);
|
2007-01-14 21:29:12 +00:00
|
|
|
list = v4;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void addNode(Node *list, Node *n) {
|
|
|
|
|
|
|
|
Node *v4 = list->_next;
|
|
|
|
|
|
|
|
if (v4 != NULL) {
|
|
|
|
v4->_prev = n;
|
|
|
|
}
|
|
|
|
|
|
|
|
n->_next = v4;
|
|
|
|
list->_next = n;
|
|
|
|
n->_prev = list;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void removeNode(Node *n) {
|
|
|
|
|
|
|
|
Node *v4 = n->_next;
|
|
|
|
if (v4 != NULL) {
|
|
|
|
v4->_prev = n->_prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
n->_prev->_next = n->_next;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
Job *Parallaction::addJob(JobFn fn, void *parm, uint16 tag) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-04 08:58:23 +00:00
|
|
|
Job *v8 = (Job*)malloc(sizeof(Job));
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
v8->_parm = parm;
|
|
|
|
v8->_fn = fn;
|
|
|
|
v8->_tag = tag;
|
|
|
|
v8->_finished = 0;
|
|
|
|
v8->_count = 0;
|
|
|
|
|
|
|
|
Job *v4 = &_jobs;
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
while (v4->_next && ((Job*)(v4->_next))->_tag > tag) {
|
|
|
|
v4 = (Job*)v4->_next;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
addNode(v4, v8);
|
2007-01-14 21:29:12 +00:00
|
|
|
return v8;
|
|
|
|
}
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
void Parallaction::removeJob(Job *j) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
removeNode(j);
|
2007-03-04 08:58:23 +00:00
|
|
|
free(j);
|
2007-01-14 21:29:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
void Parallaction::pauseJobs() {
|
2007-01-14 21:29:12 +00:00
|
|
|
_engineFlags |= kEnginePauseJobs;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
void Parallaction::resumeJobs() {
|
2007-01-14 21:29:12 +00:00
|
|
|
_engineFlags &= ~kEnginePauseJobs;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
void Parallaction::runJobs() {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
if (_engineFlags & kEnginePauseJobs) return;
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
Job *j = (Job*)_jobs._next;
|
2007-01-14 21:29:12 +00:00
|
|
|
while (j) {
|
2007-02-18 09:33:53 +00:00
|
|
|
debugC(3, kDebugJobs, "runJobs: %i", j->_tag);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
(*j->_fn)(j->_parm, j);
|
2007-03-17 13:14:50 +00:00
|
|
|
Job *v4 = (Job*)j->_next;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-02-17 15:37:49 +00:00
|
|
|
if (j->_finished == 1)
|
|
|
|
removeJob(j);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
j = v4;
|
|
|
|
}
|
|
|
|
|
2007-02-04 15:43:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
// this Job uses a static counter to delay removal
|
|
|
|
// and is in fact only used to remove jEraseLabel jobs
|
|
|
|
//
|
|
|
|
void jobWaitRemoveJob(void *parm, Job *j) {
|
|
|
|
Job *arg = (Job*)parm;
|
|
|
|
|
|
|
|
static uint16 count = 0;
|
|
|
|
|
2007-02-18 09:33:53 +00:00
|
|
|
debugC(3, kDebugJobs, "jobWaitRemoveJob: count = %i", count);
|
2007-02-04 11:16:40 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
_engineFlags |= kEngineMouse;
|
|
|
|
|
|
|
|
count++;
|
|
|
|
if (count == 2) {
|
|
|
|
count = 0;
|
2007-03-17 13:14:50 +00:00
|
|
|
_vm->removeJob(arg);
|
2007-01-14 21:29:12 +00:00
|
|
|
_engineFlags &= ~kEngineMouse;
|
|
|
|
j->_finished = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-02-19 13:07:18 +00:00
|
|
|
void Parallaction::initTable(const char *path, char** table) {
|
|
|
|
// printf("initTable(%s)\n", path);
|
|
|
|
|
|
|
|
Common::File stream;
|
|
|
|
|
|
|
|
if (!stream.open(path))
|
|
|
|
errorFileNotFound(path);
|
|
|
|
|
|
|
|
uint16 count = 0;
|
|
|
|
|
2007-02-19 22:34:00 +00:00
|
|
|
fillBuffers(stream);
|
2007-02-19 13:07:18 +00:00
|
|
|
|
|
|
|
while (scumm_stricmp(_tokens[0], "ENDTABLE")) {
|
|
|
|
|
2007-03-04 08:58:23 +00:00
|
|
|
table[count] = (char*)malloc(strlen(_tokens[0])+1);
|
2007-02-19 13:07:18 +00:00
|
|
|
strcpy(table[count], _tokens[0]);
|
|
|
|
|
|
|
|
count++;
|
2007-02-19 22:34:00 +00:00
|
|
|
fillBuffers(stream);
|
2007-02-19 13:07:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
table[count] = NULL;
|
|
|
|
|
|
|
|
stream.close();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::freeTable(char** table) {
|
|
|
|
|
|
|
|
uint16 count = 0;
|
|
|
|
|
|
|
|
while (table[count]) {
|
|
|
|
|
2007-03-04 08:58:23 +00:00
|
|
|
free(table[count]);
|
2007-02-19 13:07:18 +00:00
|
|
|
table[count] = NULL;
|
|
|
|
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 Parallaction::searchTable(const char *s, const char **table) {
|
|
|
|
|
|
|
|
int16 count = 0;
|
|
|
|
|
|
|
|
if (!s) return 0;
|
|
|
|
|
|
|
|
while (table[count]) {
|
|
|
|
if (!scumm_stricmp(table[count], s)) return count + 1;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
} // namespace Parallaction
|