Пример #1
0
Common::Error LabEngine::run() {
	if (getFeatures() & GF_LOWRES)
		initGraphics(320, 200, false);
	else
		initGraphics(640, 480, true);

	_event = new EventManager(this);
	_resource = new Resource(this);
	_music = new Music(this);
	_graphics = new DisplayMan(this);
	_anim = new Anim(this);
	_specialLocks = new SpecialLocks(this);
	_utils = new Utils(this);
	_console = new Console(this);
	_journalBackImage = new Image(this);

	if (getPlatform() == Common::kPlatformWindows) {
		// Check if this is the Wyrmkeep trial
		Common::File roomFile;
		bool knownVersion = true;
		bool roomFileOpened = roomFile.open("game/rooms/48");

		if (!roomFileOpened)
			knownVersion = false;
		else if (roomFile.size() != 892)
			knownVersion = false;
		else {
			roomFile.seek(352);
			byte checkByte = roomFile.readByte();
			if (checkByte == 0x00) {
				// Full Windows version
			} else if (checkByte == 0x80) {
				// Wyrmkeep trial version
				_extraGameFeatures = GF_WINDOWS_TRIAL;

				GUI::MessageDialog trialMessage("This is a trial Windows version of the game. To play the full version, you will need to use the original interpreter and purchase a key from Wyrmkeep");
				trialMessage.runModal();
			} else {
				knownVersion = false;
			}

			roomFile.close();

			if (!knownVersion) {
				warning("Unknown Windows version found, please report this version to the ScummVM team");
				return Common::kNoGameDataFoundError;
			}
		}
	}

	go();

	return Common::kNoError;
}
Пример #2
0
void LabEngine::doActions(const ActionList &actionList) {
	ActionList::const_iterator action;
	for (action = actionList.begin(); action != actionList.end(); ++action) {
		updateEvents();
		if (_quitLab || shouldQuit())
			return;

		switch (action->_actionType) {
		case kActionPlaySound:
			_music->loadSoundEffect(action->_messages[0], false, true);
			break;

		case kActionPlaySoundNoWait:	// only used in scene 7 (street, when teleporting to the surreal maze)
			_music->loadSoundEffect(action->_messages[0], false, false);
			break;

		case kActionPlaySoundLooping:
			_music->loadSoundEffect(action->_messages[0], true, false);
			break;

		case kActionShowDiff:
			_graphics->readPict(action->_messages[0], true);
			break;

		case kActionShowDiffLooping:	// used in scene 44 (heart of the labyrinth, minotaur)
			_graphics->readPict(action->_messages[0], false);
			break;

		case kActionLoadDiff:
			if (!action->_messages[0].empty())
				// Puts a file into memory
				_graphics->loadPict(action->_messages[0]);
			break;

		case kActionLoadBitmap:
			error("Unused opcode kActionLoadBitmap has been called");

		case kActionShowBitmap:
			error("Unused opcode kActionShowBitmap has been called");

		case kActionTransition:
			_graphics->doTransition((TransitionType)action->_param1, action->_messages[0].c_str());
			break;

		case kActionNoUpdate:
			_noUpdateDiff = true;
			_anim->_doBlack = false;
			break;

		case kActionForceUpdate:
			_curFileName = " ";
			break;

		case kActionShowCurPict: {
			Common::String test = getPictName(true);

			if (test != _curFileName) {
				_curFileName = test;
				_graphics->readPict(_curFileName);
			}
			}
			break;

		case kActionSetElement:
			_conditions->inclElement(action->_param1);
			break;

		case kActionUnsetElement:
			_conditions->exclElement(action->_param1);
			break;

		case kActionShowMessage:
			if (_graphics->_longWinInFront)
				_graphics->longDrawMessage(action->_messages[0], true);
			else
				_graphics->drawMessage(action->_messages[0], true);
			break;

		case kActionCShowMessage:
			if (!_closeDataPtr)
				_graphics->drawMessage(action->_messages[0], true);
			break;

		case kActionShowMessages:
			_graphics->drawMessage(action->_messages[_utils->getRandom(action->_param1)], true);
			break;

		case kActionChangeRoom:
			if (action->_param1 & 0x8000) {
				// This is a Wyrmkeep Windows trial version, thus stop at this
				// point, since we can't check for game payment status
				_graphics->readPict(getPictName(true));
				GUI::MessageDialog trialMessage("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep");
				trialMessage.runModal();
				break;
			}

			_music->checkRoomMusic(_roomNum, action->_param1);
			_roomNum   = action->_param1;
			_direction = action->_param2 - 1;
			_closeDataPtr = nullptr;
			_anim->_doBlack = true;
			break;

		case kActionSetCloseup: {
			Common::Point curPos = Common::Point(_utils->scaleX(action->_param1), _utils->scaleY(action->_param2));
				const CloseData *tmpClosePtr = getObject(curPos, _closeDataPtr);

				if (tmpClosePtr)
					_closeDataPtr = tmpClosePtr;
			}
			break;

		case kActionMainView:
			_closeDataPtr = nullptr;
			break;

		case kActionSubInv:
			if (_inventory[action->_param1]._quantity)
				(_inventory[action->_param1]._quantity)--;

			if (_inventory[action->_param1]._quantity == 0)
				_conditions->exclElement(action->_param1);

			break;

		case kActionAddInv:
			(_inventory[action->_param1]._quantity) += action->_param2;
			_conditions->inclElement(action->_param1);
			break;

		case kActionShowDir:
			_graphics->setActionMessage(false);
			break;

		case kActionWaitSecs: {
				uint32 targetMillis = _system->getMillis() + action->_param1 * 1000;

				_graphics->screenUpdate();

				while (_system->getMillis() < targetMillis) {
					updateEvents();
					if (_quitLab || shouldQuit())
						return;
					_anim->diffNextFrame();
				}
			}
			break;

		case kActionStopMusic:	// used in scene 44 (heart of the labyrinth, minotaur)
			_music->freeMusic();
			break;

		case kActionStartMusic:	// unused
			error("Unused opcode kActionStartMusic has been called");
			break;

		case kActionChangeMusic:	// used in scene 46 (museum exhibit, for the alarm)
			_music->changeMusic(action->_messages[0], true, false);
			break;

		case kActionResetMusic:	// used in scene 45 (sheriff's office, after museum)
			_music->resetMusic(true);
			break;

		case kActionFillMusic:
			error("Unused opcode kActionFillMusic has been called");
			break;

		case kActionWaitSound:	// used in scene 44 (heart of the labyrinth / ending)
			while (_music->isSoundEffectActive()) {
				updateEvents();
				if (_quitLab || shouldQuit())
					return;
				_anim->diffNextFrame();
				waitTOF();
			}
			break;

		case kActionClearSound:
			_music->stopSoundEffect();
			break;

		case kActionWinMusic:	// used in scene 44 (heart of the labyrinth / ending)
			_music->freeMusic();
			_music->changeMusic("Music:WinGame", false, false);
			break;

		case kActionWinGame:	// used in scene 44 (heart of the labyrinth / ending)
			_quitLab = true;
			showLab2Teaser();
			break;

		case kActionLostGame:
			error("Unused opcode kActionLostGame has been called");

		case kActionResetBuffer:
			_graphics->freePict();
			break;

		case kActionSpecialCmd:
			if (action->_param1 == 0)
				_anim->_doBlack = true;
			else if (action->_param1 == 1)
				_anim->_doBlack = (_closeDataPtr == nullptr);
			else if (action->_param1 == 2)
				_anim->_doBlack = (_closeDataPtr != nullptr);
			else if (action->_param1 == 5) {
				// inverse the palette
				for (int idx = (8 * 3); idx < (255 * 3); idx++)
					_anim->_diffPalette[idx] = 255 - _anim->_diffPalette[idx];

				waitTOF();
				_graphics->setPalette(_anim->_diffPalette, 256);
				waitTOF();
				waitTOF();
			} else if (action->_param1 == 4) {
				// white the palette
				_graphics->whiteScreen();
				waitTOF();
				waitTOF();
			} else if (action->_param1 == 6) {
				// Restore the palette
				waitTOF();
				_graphics->setPalette(_anim->_diffPalette, 256);
				waitTOF();
				waitTOF();
			} else if (action->_param1 == 7) {
				// Quick pause
				waitTOF();
				waitTOF();
				waitTOF();
			}

			break;
		}
	}

	_music->stopSoundEffect();
}