コード例 #1
0
void Inter_Geisha::oGeisha_readData(OpFuncParams &params) {
	const char *file = _vm->_game->_script->evalString();

	uint16 dataVar = _vm->_game->_script->readVarIndex();

	debugC(2, kDebugFileIO, "Read from file \"%s\" (%d)", file, dataVar);

	WRITE_VAR(1, 1);

	SaveLoad::SaveMode mode = _vm->_saveLoad->getSaveMode(file);
	if (mode == SaveLoad::kSaveModeSave) {

		if (!_vm->_saveLoad->load(file, dataVar, 0, 0)) {

			GUI::MessageDialog dialog(_("Failed to load game state from file."));
			dialog.runModal();

		} else
			WRITE_VAR(1, 0);

		return;

	} else if (mode == SaveLoad::kSaveModeIgnore) {
		WRITE_VAR(1, 0);
		return;
	}

	warning("Attempted to read from file \"%s\"", file);
}
コード例 #2
0
void Inter_Geisha::oGeisha_writeData(OpFuncParams &params) {
	const char *file = _vm->_game->_script->evalString();

	int16 dataVar = _vm->_game->_script->readVarIndex();
	int32 size    = _vm->_game->_script->readValExpr();

	debugC(2, kDebugFileIO, "Write to file \"%s\" (%d, %d bytes)", file, dataVar, size);

	WRITE_VAR(1, 1);

	SaveLoad::SaveMode mode = _vm->_saveLoad->getSaveMode(file);
	if (mode == SaveLoad::kSaveModeSave) {

		if (!_vm->_saveLoad->save(file, dataVar, size, 0)) {

			GUI::MessageDialog dialog(_("Failed to save game state to file."));
			dialog.runModal();

		} else
			WRITE_VAR(1, 0);

	} else if (mode == SaveLoad::kSaveModeIgnore) {
		WRITE_VAR(1, 0);
		return;
	} else if (mode == SaveLoad::kSaveModeNone)
		warning("Attempted to write to file \"%s\"", file);

	WRITE_VAR(1, 0);
}
コード例 #3
0
ファイル: inter_v7.cpp プロジェクト: Templier/scummvm-test
void Inter_v7::o7_closedBase() {
	Common::String id = _vm->_game->_script->evalString();

	if (_databases.close(id))
		WRITE_VAR(27, 1); // Success
	else
		WRITE_VAR(27, 0); // Failure
}
コード例 #4
0
ファイル: draw.cpp プロジェクト: tramboi/scummvm-test
void Draw::printTextCentered(int16 id, int16 left, int16 top, int16 right,
		int16 bottom, const char *str, int16 fontIndex, int16 color) {

	adjustCoords(1, &left, &top);
	adjustCoords(1, &right, &bottom);

	uint16 centerOffset = _vm->_game->_script->getFunctionOffset(TOTFile::kFunctionCenter);
	if (centerOffset != 0) {
		_vm->_game->_script->call(centerOffset);

		WRITE_VAR(17, (uint32) id);
		WRITE_VAR(18, (uint32) left);
		WRITE_VAR(19, (uint32) top);
		WRITE_VAR(20, (uint32) (right - left + 1));
		WRITE_VAR(21, (uint32) (bottom - top + 1));
		_vm->_inter->funcBlock(0);

		_vm->_game->_script->pop();
	}

	if (str[0] == '\0')
		return;

	if (fontIndex >= kFontCount) {
		warning("Draw::printTextCentered(): Font %d > Count %d", fontIndex, kFontCount);
		return;
	}

	if (!_fonts[fontIndex])
		return;

	_transparency = 1;
	_destSpriteX = left;
	_destSpriteY = top;
	_fontIndex = fontIndex;
	_frontColor = color;
	_textToPrint = str;

	Font &font = *_fonts[fontIndex];

	int16 width = 0;
	if (!font.isMonospaced()) {
		const char *s = str;
		while (*s != '\0')
			width += font.getCharWidth(*s++);
	}
	else
		width = strlen(str) * font.getCharWidth();

	adjustCoords(1, &width, 0);
	_destSpriteX += (right - left + 1 - width) / 2;

	spriteOperation(DRAW_PRINTTEXT);
}
コード例 #5
0
ファイル: inter_v7.cpp プロジェクト: Templier/scummvm-test
void Inter_v7::o7_opendBase() {
	Common::String dbFile = _vm->_game->_script->evalString();
	Common::String id     = _vm->_game->_script->evalString();

	dbFile += ".DBF";

	_databases.setLanguage(_vm->_language);
	if (!_databases.open(id, dbFile)) {
		WRITE_VAR(27, 0); // Failure
		return;
	}

	WRITE_VAR(27, 1); // Success
}
コード例 #6
0
ファイル: inter_bargon.cpp プロジェクト: AdamRi/scummvm-pink
void Inter_Bargon::oBargon_intro2(OpGobParams &params) {
	int i;
	int16 mouseX;
	int16 mouseY;
	MouseButtons buttons;
	SurfacePtr surface;
	SoundDesc samples[4];
	int16 comp[5] = { 0, 1, 2, 3, -1 };
	static const char *const sndFiles[] = {"1INTROII.snd", "2INTROII.snd", "1INTRO3.snd", "2INTRO3.snd"};

	surface = _vm->_video->initSurfDesc(320, 200);
	_vm->_video->drawPackedSprite("2ille.ims", *surface);
	_vm->_draw->_frontSurface->blit(*surface, 0, 0, 319, 199, 0, 0);
	_vm->_video->drawPackedSprite("2ille4.ims", *surface);
	_vm->_draw->_frontSurface->blit(*surface, 0, 0, 319, 199, 320, 0);
	_vm->_util->setScrollOffset(320, 0);
	_vm->_video->dirtyRectsAll();
	_vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0);
	_vm->_util->longDelay(1000);
	for (i = 320; i >= 0; i--) {
		_vm->_util->setScrollOffset(i, 0);
		_vm->_video->dirtyRectsAll();
		if ((_vm->_game->checkKeys(&mouseX, &mouseY, &buttons, 0) == kKeyEscape) ||
				_vm->shouldQuit()) {
			_vm->_palAnim->fade(0, -2, 0);
			_vm->_draw->_frontSurface->clear();
			memset((char *)_vm->_draw->_vgaPalette, 0, 768);
			WRITE_VAR(4, buttons);
			WRITE_VAR(0, kKeyEscape);
			WRITE_VAR(57, (uint32) -1);
			break;
		}
	}
	if (!_vm->shouldQuit()) {
		_vm->_util->setScrollOffset(0, 0);
		_vm->_video->dirtyRectsAll();
	}
	surface.reset();
	if (VAR(57) == ((uint32) -1))
		return;

	for (i = 0; i < 4; i++)
		_vm->_sound->sampleLoad(&samples[i], SOUND_SND, sndFiles[i]);
	_vm->_sound->blasterPlayComposition(comp, 0, samples, 4);
	_vm->_sound->blasterWaitEndPlay(true, false);
	_vm->_palAnim->fade(0, 0, 0);
	_vm->_draw->_frontSurface->clear();
}
コード例 #7
0
ファイル: inter_v7.cpp プロジェクト: Templier/scummvm-test
void Inter_v7::o7_getDBString() {
	Common::String id      = _vm->_game->_script->evalString();
	Common::String group   = _vm->_game->_script->evalString();
	Common::String section = _vm->_game->_script->evalString();
	Common::String keyword = _vm->_game->_script->evalString();

	Common::String result;
	if (!_databases.getString(id, group, section, keyword, result)) {
		WRITE_VAR(27, 0); // Failure
		storeString("");
		return;
	}

	storeString(result.c_str());
	WRITE_VAR(27, 1); // Success
}
コード例 #8
0
bool Inter_Inca2::oInca2_spaceShooter(OpFuncParams &params) {
	// TODO: Not yet implemented. We'll pretend we won the match for now
	_vm->_game->_script->skip(4);
	uint16 resVar = _vm->_game->_script->readUint16();
	_vm->_game->_script->skip(4);

	WRITE_VAR(resVar, 1);
	return false;
}
コード例 #9
0
ファイル: inter_bargon.cpp プロジェクト: AdamRi/scummvm-pink
void Inter_Bargon::oBargon_intro3(OpGobParams &params) {
	int16 mouseX;
	int16 mouseY;
	MouseButtons buttons;
	Video::Color *palBak;
	SoundDesc samples[2];
	int16 comp[3] = { 0, 1, -1 };
	byte *palettes[4];
	static const char *const sndFiles[] = {"1INTROIV.snd", "2INTROIV.snd"};
	static const char *const palFiles[] = {"2ou2.clt", "2ou3.clt", "2ou4.clt", "2ou5.clt"};

	int32 size;

	for (int i = 0; i < 2; i++)
		_vm->_sound->sampleLoad(&samples[i], SOUND_SND, sndFiles[i]);
	for (int i = 0; i < 4; i++)
		palettes[i] = _vm->_dataIO->getFile(palFiles[i], size);
	palBak = _vm->_global->_pPaletteDesc->vgaPal;

	_vm->_sound->blasterPlayComposition(comp, 0, samples, 2);
	for (int i = 0; i < 20; i++) {
		for (int j = 0; j < 4; j++) {
			_vm->_global->_pPaletteDesc->vgaPal = (Video::Color *)palettes[j];
			_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
			_vm->_util->longDelay(_vm->_util->getRandom(200));
		}
		if ((_vm->_game->checkKeys(&mouseX, &mouseY, &buttons, 0) == kKeyEscape) ||
				_vm->shouldQuit()) {
			_vm->_sound->blasterStop(10);
			_vm->_palAnim->fade(0, -2, 0);
			_vm->_draw->_frontSurface->clear();
			memset(_vm->_draw->_vgaPalette, 0, 768);
			WRITE_VAR(4, buttons);
			WRITE_VAR(0, kKeyEscape);
			WRITE_VAR(57, (uint32) -1);
			break;
		}
	}
	_vm->_sound->blasterWaitEndPlay(false, false);

	_vm->_global->_pPaletteDesc->vgaPal = palBak;
	for (int i = 0; i < 4; i++)
		delete[] palettes[i];
}
コード例 #10
0
ファイル: sound.cpp プロジェクト: AndywinXp/scummvm
void Sound::blasterWaitEndPlay(bool interruptible, bool stopComp) {
	if (!_blaster)
		return;

	debugC(1, kDebugSound, "SoundBlaster: Waiting for playback to end");

	if (stopComp)
		_blaster->endComposition();

	while (_blaster->isPlaying() && !_vm->shouldQuit()) {
		if (interruptible && (_vm->_util->checkKey() == kKeyEscape)) {
			WRITE_VAR(57, (uint32) -1);
			return;
		}
		_vm->_util->longDelay(200);
	}

	_blaster->stopSound(0);
}
コード例 #11
0
bool LshKBM::save(FILE *f, unsigned char ver) const
{
  unsigned int signature = 0xFAADBEEB;
  WRITE_VAR(signature);
  ver = mVer; // added mJfinal and mDtKBinMeans
  WRITE_VAR(ver);
  WRITE_VAR(type);
  WRITE_VAR(dims);
  WRITE_VAR(num_descriptors);
  WRITE_VAR(num_images);
  unsigned int word_count = wordCount(); // how many centroids?
  WRITE_VAR(word_count);
  WRITE_VAR(mJfinal);
  WRITE_VAR(mDtKBinMeans);
  WRITE_VAR(m_guid);
  uint32_t m=mLshKbmP.getM(),l=mLshKbmP.getL();
  WRITE_VAR(m);
  WRITE_VAR(l);

  cout<<"sig="<<signature<<" ver="<<ver<<" type="<<type<<" dims="<<dims<<" #descriptors="<<num_descriptors<<" #images="<<num_images<<" #words="<<word_count<<endl;
  cout<<" mJfinal="<<mJfinal<<" mDtKBinMeans="<<mDtKBinMeans<<endl;

  // write centroids to file - decide which one to save!
  if(mCentroids.size()>0){
    for(uint32_t i=0; i<mCentroids.size(); ++i)
      WRITE_PTR(&(mCentroids[i]->bd[0]), dims*sizeof(mCentroids[i]->bd[0]));
  }else{
    Log::error("Could not determine which centroids to save to file!");
    return false;
  }
  //TODO: maybe save LSH buckets here? try without first
  // LSH table building should be quite fast.
  return true;
}
コード例 #12
0
ファイル: inter_v7.cpp プロジェクト: Templier/scummvm-test
void Inter_v7::o7_playVmdOrMusic() {
	Common::String file = _vm->_game->_script->evalString();

	VideoPlayer::Properties props;

	props.x          = _vm->_game->_script->readValExpr();
	props.y          = _vm->_game->_script->readValExpr();
	props.startFrame = _vm->_game->_script->readValExpr();
	props.lastFrame  = _vm->_game->_script->readValExpr();
	props.breakKey   = _vm->_game->_script->readValExpr();
	props.flags      = _vm->_game->_script->readValExpr();
	props.palStart   = _vm->_game->_script->readValExpr();
	props.palEnd     = _vm->_game->_script->readValExpr();
	props.palCmd     = 1 << (props.flags & 0x3F);
	props.forceSeek  = true;

	debugC(1, kDebugVideo, "Playing video \"%s\" @ %d+%d, frames %d - %d, "
			"paletteCmd %d (%d - %d), flags %X", file.c_str(),
			props.x, props.y, props.startFrame, props.lastFrame,
			props.palCmd, props.palStart, props.palEnd, props.flags);

	if (file == "RIEN") {
		_vm->_vidPlayer->closeAll();
		return;
	}

	bool close = false;
	if (props.lastFrame == -1) {
		close = true;
	} else if (props.lastFrame == -3) {

		if (file.empty()) {
			_vm->_vidPlayer->closeVideo(_vm->_mult->_objects[props.startFrame].videoSlot - 1);
			_vm->_mult->_objects[props.startFrame].videoSlot = 0;
			return;
		}

		props.flags  = VideoPlayer::kFlagOtherSurface;
		props.sprite = -1;

		_vm->_mult->_objects[props.startFrame].pAnimData->animation = -props.startFrame - 1;

		if (_vm->_mult->_objects[props.startFrame].videoSlot > 0)
			_vm->_vidPlayer->closeVideo(_vm->_mult->_objects[props.startFrame].videoSlot - 1);

		uint32 x = props.x;
		uint32 y = props.y;

		int slot = _vm->_vidPlayer->openVideo(false, file, props);

		_vm->_mult->_objects[props.startFrame].videoSlot = slot + 1;

		if (x == 0xFFFFFFFF) {
			*_vm->_mult->_objects[props.startFrame].pPosX = _vm->_vidPlayer->getDefaultX(slot);
			*_vm->_mult->_objects[props.startFrame].pPosY = _vm->_vidPlayer->getDefaultY(slot);
		} else {
			*_vm->_mult->_objects[props.startFrame].pPosX = x;
			*_vm->_mult->_objects[props.startFrame].pPosY = y;
		}

		return;
	} else if (props.lastFrame == -4) {
		warning("Woodruff Stub: Video/Music command -4: Play background video %s", file.c_str());
		return;
	} else if (props.lastFrame == -5) {
//		warning("Urban/Playtoons Stub: Stop without delay");
		_vm->_sound->bgStop();
		return;
	} else if (props.lastFrame == -6) {
//		warning("Urban/Playtoons Stub: Video/Music command -6 (cache video)");
		return;
	} else if (props.lastFrame == -7) {
//		warning("Urban/Playtoons Stub: Video/Music command -6 (flush cache)");
		return;
	} else if ((props.lastFrame == -8) || (props.lastFrame == -9)) {
		if (!file.contains('.'))
			file += ".WA8";

		probe16bitMusic(file);

		if (props.lastFrame == -9)
			debugC(0, kDebugVideo, "Urban/Playtoons Stub: Delayed music stop?");

		_vm->_sound->bgStop();
		_vm->_sound->bgPlay(file.c_str(), SOUND_WAV);
		return;
	} else if (props.lastFrame <= -10) {
		_vm->_vidPlayer->closeVideo();

		if (!(props.flags & VideoPlayer::kFlagNoVideo))
			props.loop = true;

	} else if (props.lastFrame < 0) {
		warning("Urban/Playtoons Stub: Unknown Video/Music command: %d, %s", props.lastFrame, file.c_str());
		return;
	}

	if (props.startFrame == -2) {
		props.startFrame = 0;
		props.lastFrame  = -1;
		props.noBlock    = true;
	}

	_vm->_vidPlayer->evaluateFlags(props);

	bool primary = true;
	if (props.noBlock && (props.flags & VideoPlayer::kFlagNoVideo))
		primary = false;

	int slot = 0;
	if (!file.empty() && ((slot = _vm->_vidPlayer->openVideo(primary, file, props)) < 0)) {
		WRITE_VAR(11, (uint32) -1);
		return;
	}

	if (props.hasSound)
		_vm->_vidPlayer->closeLiveSound();

	if (props.startFrame >= 0)
		_vm->_vidPlayer->play(slot, props);

	if (close && !props.noBlock) {
		if (!props.canceled)
			_vm->_vidPlayer->waitSoundEnd(slot);
		_vm->_vidPlayer->closeVideo(slot);
	}

}
コード例 #13
0
ファイル: game.cpp プロジェクト: Bundesdrucker/scummvm
void Game::playTot(int16 function) {
	int16 *oldNestLevel      = _vm->_inter->_nestLevel;
	int16 *oldBreakFrom      = _vm->_inter->_breakFromLevel;
	int16 *oldCaptureCounter = _vm->_scenery->_pCaptureCounter;

	_script->push();

	int16 captureCounter = 0;
	int16 breakFrom;
	int16 nestLevel;
	_vm->_inter->_nestLevel         = &nestLevel;
	_vm->_inter->_breakFromLevel    = &breakFrom;
	_vm->_scenery->_pCaptureCounter = &captureCounter;

	Common::String oldTotFile;

	if (function <= 0) {
		while (!_vm->shouldQuit()) {
			if (_vm->_inter->_variables)
				_vm->_draw->animateCursor(4);

			if (function != -1) {
				_vm->_inter->initControlVars(1);

				for (int i = 0; i < 4; i++) {
					_vm->_draw->_fontToSprite[i].sprite = -1;
					_vm->_draw->_fontToSprite[i].base = -1;
					_vm->_draw->_fontToSprite[i].width = -1;
					_vm->_draw->_fontToSprite[i].height = -1;
				}

				// Gobliiins music stopping
				if (_vm->getGameType() == kGameTypeGob1) {
					_vm->_sound->adlibStop();
					_vm->_sound->cdStop();
				}

				_vm->_mult->initAll();
				_vm->_mult->zeroMultData();

				_vm->_draw->_spritesArray[Draw::kFrontSurface] = _vm->_draw->_frontSurface;
				_vm->_draw->_spritesArray[Draw::kBackSurface ] = _vm->_draw->_backSurface;
				_vm->_draw->_cursorSpritesBack = _vm->_draw->_cursorSprites;
			} else
				_vm->_inter->initControlVars(0);

			_vm->_draw->_cursorHotspotXVar = -1;
			_totToLoad.clear();

			if ((_curTotFile.empty()) && (!_script->isLoaded()))
				break;

			if (function == -2) {
				_vm->_vidPlayer->closeVideo();
				function = 0;
			}

			if (!_script->load(_curTotFile)) {
				_vm->_draw->blitCursor();
				_vm->_inter->_terminate = 2;
				break;
			}

			_resources->load(_curTotFile);

			_vm->_global->_inter_animDataSize = _script->getAnimDataSize();
			if (!_vm->_inter->_variables)
				_vm->_inter->allocateVars(_script->getVariablesCount() & 0xFFFF);

			_script->seek(_script->getFunctionOffset(TOTFile::kFunctionStart));

			_vm->_inter->renewTimeInVars();

			if (_vm->_inter->_variables) {
				WRITE_VAR(13, _vm->_global->_useMouse);
				WRITE_VAR(14, _vm->_global->_soundFlags);
				WRITE_VAR(15, _vm->_global->_fakeVideoMode);

				if (_vm->getGameType() == kGameTypeGeisha)
					WRITE_VAR(57, _vm->_global->_language);
				else
					WRITE_VAR(16, _vm->_global->_language);

				// WORKAROUND: Inca2 seems to depend on that variable to be cleared
				if (_vm->getGameType() == kGameTypeInca2)
					WRITE_VAR(59, 0);
			}

			_vm->_inter->callSub(2);

			if (!_totToLoad.empty())
				_vm->_inter->_terminate = 0;

			_vm->_draw->blitInvalidated();

			_script->unload();

			_resources->unload();

			for (int i = 0; i < *_vm->_scenery->_pCaptureCounter; i++)
				capturePop(0);

			if (function != -1) {
				_vm->_goblin->freeObjects();

				_vm->_sound->blasterStop(0);

				for (int i = 0; i < Sound::kSoundsCount; i++) {
					SoundDesc *sound = _vm->_sound->sampleGetBySlot(i);

					if (sound &&
					   ((sound->getType() == SOUND_SND) || (sound->getType() == SOUND_WAV)))
						_vm->_sound->sampleFree(sound);
				}
			}

			_vm->_draw->closeAllWin();

			if (_totToLoad.empty())
				break;

			_curTotFile = _totToLoad;

		}
	} else {
		_vm->_inter->initControlVars(0);
		_vm->_scenery->_pCaptureCounter = oldCaptureCounter;

		if (function > 13)
			_script->seek(function);
		else
			_script->seek(_script->getFunctionOffset(function + 1));

		_vm->_inter->callSub(2);

		if (_vm->_inter->_terminate != 0)
			_vm->_inter->_terminate = 2;
	}

	_curTotFile = oldTotFile;

	_vm->_inter->_nestLevel         = oldNestLevel;
	_vm->_inter->_breakFromLevel    = oldBreakFrom;
	_vm->_scenery->_pCaptureCounter = oldCaptureCounter;

	_script->pop();
}
コード例 #14
0
HRESULT DD_API MyDirectDrawClipperProxy::SetHWnd(DWORD dwFlags, HWND hWnd)
{
    LOG_FUNCTION();
    WRITE_VAR(hWnd);
    return mClipper->SetHWnd(dwFlags, hWnd);
}
コード例 #15
0
ファイル: inter_v6.cpp プロジェクト: havlenapetr/Scummvm
void Inter_v6::o6_playVmdOrMusic() {
	char fileName[128];
	int16 x, y;
	int16 startFrame;
	int16 lastFrame;
	int16 breakKey;
	int16 flags;
	int16 palStart;
	int16 palEnd;
	uint16 palCmd;
	bool close;

	_vm->_game->_script->evalExpr(0);
	strncpy0(fileName, _vm->_game->_script->getResultStr(), 127);

	x = _vm->_game->_script->readValExpr();
	y = _vm->_game->_script->readValExpr();
	startFrame = _vm->_game->_script->readValExpr();
	lastFrame = _vm->_game->_script->readValExpr();
	breakKey = _vm->_game->_script->readValExpr();
	flags = _vm->_game->_script->readValExpr();
	palStart = _vm->_game->_script->readValExpr();
	palEnd = _vm->_game->_script->readValExpr();
	palCmd = 1 << (flags & 0x3F);

	debugC(1, kDebugVideo, "Playing video \"%s\" @ %d+%d, frames %d - %d, "
			"paletteCmd %d (%d - %d), flags %X", fileName, x, y, startFrame, lastFrame,
			palCmd, palStart, palEnd, flags);

	close = false;
	if (lastFrame == -1) {
		close = true;
	} else if (lastFrame == -5) {
		_vm->_sound->bgStop();
		return;
	} else if (lastFrame == -9) {
		if (!strchr(fileName, '.'))
			strcat(fileName, ".WA8");

		probe16bitMusic(fileName);

		_vm->_sound->bgStop();
		_vm->_sound->bgPlay(fileName, SOUND_WAV);
		return;
	} else if (lastFrame == -10) {
		_vm->_vidPlayer->primaryClose();
		warning("Urban Stub: Video/Music command -10 (close video?)");
		return;
	} else if (lastFrame < 0) {
		warning("Unknown Video/Music command: %d, %s", lastFrame, fileName);
		return;
	}

	if (startFrame == -2) {
		startFrame = 0;
		lastFrame = -1;
		close = false;
	}

	if ((fileName[0] != 0) && !_vm->_vidPlayer->primaryOpen(fileName, x, y, flags)) {
		WRITE_VAR(11, (uint32) -1);
		return;
	}

	if (startFrame >= 0)
		_vm->_vidPlayer->primaryPlay(startFrame, lastFrame, breakKey,
				palCmd, palStart, palEnd, 0, -1, false, -1, true);

	if (close)
		_vm->_vidPlayer->primaryClose();
}
コード例 #16
0
ファイル: draw.cpp プロジェクト: tramboi/scummvm-test
void Draw::oPlaytoons_sub_F_1B(uint16 id, int16 left, int16 top, int16 right, int16 bottom,
		char *paramStr, int16 fontIndex, int16 var4, int16 shortId) {

	int16 width;
	char tmpStr[128];

	strcpy(tmpStr, paramStr);
	adjustCoords(1, &left, &top);
	adjustCoords(1, &right,  &bottom);

	uint16 centerOffset = _vm->_game->_script->getFunctionOffset(TOTFile::kFunctionCenter);
	if (centerOffset != 0) {
		_vm->_game->_script->call(centerOffset);

		WRITE_VAR(17, (uint32) id & 0x7FFF);
		WRITE_VAR(18, (uint32) left);
		WRITE_VAR(19, (uint32) top);
		WRITE_VAR(20, (uint32) (right - left + 1));
		WRITE_VAR(21, (uint32) (bottom - top + 1));

		if (_vm->_game->_script->peekUint16(41) >= '4') {
			WRITE_VAR(22, (uint32) fontIndex);
			WRITE_VAR(23, (uint32) var4);
			if (id & 0x8000)
				WRITE_VAR(24, (uint32) 1);
			else
				WRITE_VAR(24, (uint32) 0);
			WRITE_VAR(25, (uint32) shortId);
			if (_hotspotText)
				Common::strlcpy(_hotspotText, paramStr, 40);
		}
		_vm->_inter->funcBlock(0);
		_vm->_game->_script->pop();
	}

	strcpy(paramStr, tmpStr);

	if (fontIndex >= kFontCount) {
		warning("Draw::oPlaytoons_sub_F_1B(): Font %d > Count %d", fontIndex, kFontCount);
		return;
	}

	if (!_fonts[fontIndex])
		return;

	if (*paramStr) {
		_transparency = 1;
		_fontIndex = fontIndex;
		_frontColor = var4;
		if (_vm->_game->_script->peekUint16(41) >= '4' && strchr(paramStr, 92)) {
			char str[80];
			char *str2;
			int16 strLen= 0;
			int16 offY, deltaY;

			str2 = paramStr;
			do {
				strLen++;
				str2++;
				str2 = strchr(str2, 92);
			} while (str2);
			deltaY = (bottom - right + 1 - (strLen * _fonts[fontIndex]->getCharHeight())) / (strLen + 1);
			offY = right + deltaY;
			for (int i = 0; paramStr[i]; i++) {
				int j = 0;
				while (paramStr[i] && paramStr[i] != 92)
					str[j++] = paramStr[i++];
				str[j] = 0;
				_destSpriteX = left;
				_destSpriteY = offY;
				_textToPrint = str;
				width = stringLength(str, fontIndex);
				adjustCoords(1, &width, NULL);
				_destSpriteX += (top - left + 1 - width) / 2;
				spriteOperation(DRAW_PRINTTEXT);
				offY += deltaY + _fonts[fontIndex]->getCharHeight();
			}
		} else {
			_destSpriteX = left;
			if (_vm->_game->_script->peekUint16(41) >= '4')
				_destSpriteY = right + (bottom - right + 1 - _fonts[fontIndex]->getCharHeight()) / 2;
			else
				_destSpriteY = right;
			_textToPrint = paramStr;
			width = stringLength(paramStr, fontIndex);
			adjustCoords(1, &width, NULL);
			_destSpriteX += (top - left + 1 - width) / 2;
			spriteOperation(DRAW_PRINTTEXT);
		}
	}

	return;
}
コード例 #17
0
ファイル: goblin_v2.cpp プロジェクト: 33d/scummvm
void Goblin_v2::handleGoblins() {
	Mult::Mult_Object *obj0, *obj1;
	Mult::Mult_AnimData *anim0, *anim1;
	int16 pass;
	int16 gob1State, gob2State;
	int16 gob1X, gob2X;
	int16 gob1Y, gob2Y;
	int16 gob1DestX, gob2DestX;
	int16 gob1DestY, gob2DestY;

	obj0 = &_vm->_mult->_objects[0];
	obj1 = &_vm->_mult->_objects[1];
	anim0 = obj0->pAnimData;
	anim1 = obj1->pAnimData;

	gob1State = anim0->state;
	gob2State = anim1->state;

	if (!anim0->isBusy) {
		if (!_gob1Busy && (anim0->isStatic == 0)) {
			if ((VAR(_gob1RelaxTimeVar) == 0) && (gob1State == 28)) {
				// Goblin 1 showing boredom
				gob1State = _vm->_util->getRandom(3) + 24;
				setState(0, gob1State);
				WRITE_VAR(_gob1RelaxTimeVar, 100);
			} else
				WRITE_VAR(_gob1RelaxTimeVar, VAR(_gob1RelaxTimeVar) - 1);
		}
		if ((gob1State == 8) || (gob1State == 9) || (gob1State == 29))
			anim0->curLookDir = 6;
	}
	if (!anim1->isBusy) {
		if (!_gob2Busy && (anim1->isStatic == 0)) {
			if ((VAR(_gob2RelaxTimeVar) == 0) && (gob2State == 28)) {
				// Goblin 2 showing boredom
				gob2State = _vm->_util->getRandom(3) + 24;
				setState(1, gob2State);
				WRITE_VAR(_gob2RelaxTimeVar, 100);
			} else
				WRITE_VAR(_gob2RelaxTimeVar, VAR(_gob2RelaxTimeVar) - 1);
		}
		if ((gob2State == 8) || (gob2State == 9) || (gob2State == 29))
			anim1->curLookDir = 6;
	}

	if ((anim0->isBusy == 1) && (anim0->isStatic == 0) &&
			((anim0->state == 28) || (anim0->state == 29)))
		anim0->curLookDir = 0;
	if ((anim1->isBusy == 1) && (anim1->isStatic == 0) &&
			((anim1->state == 28) || (anim1->state == 29)))
		anim1->curLookDir = 0;

	if (VAR(18) != ((uint32) -1)) {
		if (anim0->layer == 44)
			anim0->curLookDir = 4;
		else if (anim0->layer == 45)
			anim0->curLookDir = 0;
		if (anim0->isBusy == 0)
			anim0->curLookDir = 6;
	}
	if (VAR(19) != ((uint32) -1)) {
		if (anim1->layer == 48)
			anim1->curLookDir = 4;
		else if (anim1->layer == 49)
			anim1->curLookDir = 0;
		if (anim1->isBusy == 0)
			anim1->curLookDir = 6;
	}

	if ((anim0->layer == 45) && (anim0->curLookDir == 4) && (anim0->pathExistence == 5) &&
			(VAR(18) == ((uint32) -1)) && !_gob1NoTurn) {
		setState(0, 19); // Turning right->left
	}
	if ((anim0->layer == 44) && (anim0->curLookDir == 0) && (anim0->pathExistence == 5) &&
			(VAR(18) == ((uint32) -1)) && !_gob1NoTurn) {
		setState(0, 16); // Turning left->right
	}
	if ((anim1->layer == 49) && (anim1->curLookDir == 4) && (anim1->pathExistence == 5) &&
			(VAR(19) == ((uint32) -1)) && !_gob2NoTurn) {
		setState(1, 19); // Turning right->left
	}
	if ((anim1->layer == 48) && (anim1->curLookDir == 0) && (anim1->pathExistence == 5) &&
			(VAR(19) == ((uint32) -1)) && !_gob2NoTurn) {
		setState(1, 16); // Turning left->right
	}

	gob1X = obj0->goblinX;
	gob2X = obj1->goblinX;
	gob1Y = obj0->goblinY;
	gob2Y = obj1->goblinY;
	gob1DestX = anim0->destX;
	gob2DestX = anim1->destX;
	gob1DestY = anim0->destY;
	gob2DestY = anim1->destY;

	pass = _vm->_map->getPass(gob1X, gob1Y);
	if ((pass > 17) && (pass < 21)) // Ladders, ropes, stairs
		updateLayer1(anim0);
	pass = _vm->_map->getPass(gob2X, gob2Y);
	if ((pass > 17) && (pass < 21)) // Ladders, ropes, stairs
		updateLayer2(anim1);

	if ((gob1DestX < 0) || (gob1DestX > 39) || (gob1DestY < 0) || (gob1DestY > 39))
		return;

	if (gob1Y > gob1DestY) {
		if (_vm->_map->getPass(gob1DestX, gob1DestY) > 17) {
			do {
				gob1DestY--;
			} while (_vm->_map->getPass(gob1DestX, gob1DestY) > 17);
			gob1DestY++;
			if (_vm->_map->getPass(gob1DestX - 1, gob1DestY) == 0) {
				if (_vm->_map->getPass(gob1DestX + 1, gob1DestY) != 0)
					gob1DestX++;
			} else
				gob1DestX--;
			move(gob1DestX, gob1DestY, 0);
		}
	} else {
		if (_vm->_map->getPass(gob1DestX, gob1DestY) > 17) {
			do {
				gob1DestY++;
			} while (_vm->_map->getPass(gob1DestX, gob1DestY) > 17);
			gob1DestY--;
			if (_vm->_map->getPass(gob1DestX - 1, gob1DestY) == 0) {
				if (_vm->_map->getPass(gob1DestX + 1, gob1DestY) != 0)
					gob1DestX++;
			} else
				gob1DestX--;
			move(gob1DestX, gob1DestY, 0);
		}
	}
	if (gob2Y > gob2DestY) {
		if (_vm->_map->getPass(gob2DestX, gob2DestY) > 17) {
			do {
				gob2DestY--;
			} while (_vm->_map->getPass(gob2DestX, gob2DestY) > 17);
			gob2DestY++;
			if (_vm->_map->getPass(gob2DestX - 1, gob2DestY) == 0) {
				if (_vm->_map->getPass(gob2DestX + 1, gob2DestY) != 0)
					gob2DestX++;
			} else
				gob2DestX--;
			move(gob2DestX, gob2DestY, 1);
		}
	} else {
		if (_vm->_map->getPass(gob2DestX, gob2DestY) > 17) {
			do {
				gob2DestY++;
			} while (_vm->_map->getPass(gob2DestX, gob2DestY) > 17);
			gob2DestY--;
			if (_vm->_map->getPass(gob2DestX - 1, gob2DestY) == 0) {
				if (_vm->_map->getPass(gob2DestX + 1, gob2DestY) != 0)
					gob2DestX++;
			} else
				gob2DestX--;
			move(gob2DestX, gob2DestY, 1);
		}
	}
}
コード例 #18
0
ファイル: inter_v7.cpp プロジェクト: Templier/scummvm-test
void Inter_v7::o7_gob0x201(OpGobParams &params) {
	uint16 varIndex = _vm->_game->_script->readUint16();

	WRITE_VAR(varIndex, 1);
}
コード例 #19
0
ファイル: inter_v6.cpp プロジェクト: Templier/scummvm-test
void Inter_v6::o6_playVmdOrMusic() {
	Common::String file = _vm->_game->_script->evalString();

	VideoPlayer::Properties props;

	props.x          = _vm->_game->_script->readValExpr();
	props.y          = _vm->_game->_script->readValExpr();
	props.startFrame = _vm->_game->_script->readValExpr();
	props.lastFrame  = _vm->_game->_script->readValExpr();
	props.breakKey   = _vm->_game->_script->readValExpr();
	props.flags      = _vm->_game->_script->readValExpr();
	props.palStart   = _vm->_game->_script->readValExpr();
	props.palEnd     = _vm->_game->_script->readValExpr();
	props.palCmd     = 1 << (props.flags & 0x3F);
	props.forceSeek  = true;

	debugC(1, kDebugVideo, "Playing video \"%s\" @ %d+%d, frames %d - %d, "
			"paletteCmd %d (%d - %d), flags %X", file.c_str(),
			props.x, props.y, props.startFrame, props.lastFrame,
			props.palCmd, props.palStart, props.palEnd, props.flags);

	// WORKAROUND: When taking the music sheet from Dr. Dramish's car,
	//             the video that lets the sheet vanish is missing. We'll
	//             play the one where the sheet is already gone instead.
	if (_vm->isCurrentTot("avt005.tot") && file.equalsIgnoreCase("MXRAMPART"))
		file = "PLCOFDR2";

	if (file == "RIEN") {
		_vm->_vidPlayer->closeAll();
		return;
	}

	bool close = false;
	if (props.lastFrame == -1) {
		close = true;
	} else if (props.lastFrame == -5) {
//		warning("Urban/Playtoons Stub: Stop without delay");
		_vm->_sound->bgStop();
		return;
	} else if (props.lastFrame == -6) {
//		warning("Urban/Playtoons Stub: Video/Music command -6 (cache video)");
		return;
	} else if (props.lastFrame == -7) {
//		warning("Urban/Playtoons Stub: Video/Music command -6 (flush cache)");
		return;
	} else if ((props.lastFrame == -8) || (props.lastFrame == -9)) {
		if (!file.contains('.'))
			file += ".WA8";

		probe16bitMusic(file);

		if (props.lastFrame == -9)
			debugC(0, kDebugVideo, "Urban/Playtoons Stub: Delayed music stop?");

		_vm->_sound->bgStop();
		_vm->_sound->bgPlay(file.c_str(), SOUND_WAV);
		return;
	} else if (props.lastFrame <= -10) {
		_vm->_vidPlayer->closeVideo();

		if (!(props.flags & VideoPlayer::kFlagNoVideo))
			props.loop = true;

	} else if (props.lastFrame < 0) {
		warning("Urban/Playtoons Stub: Unknown Video/Music command: %d, %s", props.lastFrame, file.c_str());
		return;
	}

	if (props.startFrame == -2) {
		props.startFrame = 0;
		props.lastFrame  = -1;
		props.noBlock    = true;
	}

	_vm->_vidPlayer->evaluateFlags(props);

	bool primary = true;
	if (props.noBlock && (props.flags & VideoPlayer::kFlagNoVideo))
		primary = false;

	int slot = 0;
	if (!file.empty() && ((slot = _vm->_vidPlayer->openVideo(primary, file, props)) < 0)) {
		WRITE_VAR(11, (uint32) -1);
		return;
	}

	if (props.hasSound)
		_vm->_vidPlayer->closeLiveSound();

	if (props.startFrame >= 0)
		_vm->_vidPlayer->play(slot, props);

	if (close && !props.noBlock) {
		if (!props.canceled)
			_vm->_vidPlayer->waitSoundEnd(slot);
		_vm->_vidPlayer->closeVideo(slot);
	}

}
コード例 #20
0
ファイル: videoplayer.cpp プロジェクト: Termimad/scummvm
int VideoPlayer::openVideo(bool primary, const Common::String &file, Properties &properties) {
	int slot = 0;

	Video *video = 0;
	if (!primary) {
		slot = getNextFreeSlot();
		if (slot < 0) {
			warning("VideoPlayer::openVideo(): Can't open video \"%s\": No free slot", file.c_str());
			return -1;
		}

		video = &_videoSlots[slot];
	} else
		video = &_videoSlots[0];

	// Different video already in the slot => close that video
	if (!video->isEmpty() && (video->fileName.compareToIgnoreCase(file) != 0))
		video->close();

	// No video => load the requested file
	if (video->isEmpty()) {
		// Open the video
		if (!(video->decoder = openVideo(file, properties)))
			return -1;

		if (video->decoder->hasVideo() && !(properties.flags & kFlagNoVideo) &&
		    (video->decoder->isPaletted() != !_vm->isTrueColor())) {
			if (!properties.switchColorMode)
				return -1;

			_vm->setTrueColor(!video->decoder->isPaletted());

			video->decoder->colorModeChanged();
		}

		// Set the filename
		video->fileName = file;

		// WORKAROUND: In some rare cases, the cursor should still be
		// displayed while a video is playing.
		_noCursorSwitch = false;
		if (primary && (_vm->getGameType() == kGameTypeLostInTime)) {
			if (!file.compareToIgnoreCase("PORTA03") ||
			    !file.compareToIgnoreCase("PORTA03A") ||
			    !file.compareToIgnoreCase("CALE1") ||
			    !file.compareToIgnoreCase("AMIL2") ||
			    !file.compareToIgnoreCase("AMIL3B") ||
			    !file.compareToIgnoreCase("DELB"))
				_noCursorSwitch = true;
		}

		// WORKAROUND: In Woodruff, Coh Cott vanished in one video on her party.
		// This is a bug in video, so we work around it.
		_woodruffCohCottWorkaround = false;
		if (primary && (_vm->getGameType() == kGameTypeWoodruff)) {
			if (!file.compareToIgnoreCase("SQ32-03"))
				_woodruffCohCottWorkaround = true;
		}

		if (!(properties.flags & kFlagNoVideo) && (properties.sprite >= 0)) {
			bool ownSurf    = (properties.sprite != Draw::kFrontSurface) && (properties.sprite != Draw::kBackSurface);
			bool screenSize = properties.flags & kFlagScreenSurface;

			if (ownSurf) {
				_vm->_draw->_spritesArray[properties.sprite] =
					_vm->_video->initSurfDesc(screenSize ? _vm->_width  : video->decoder->getWidth(),
					                          screenSize ? _vm->_height : video->decoder->getHeight(), 0);
			}

			if (!_vm->_draw->_spritesArray[properties.sprite] &&
			    (properties.sprite != Draw::kFrontSurface) &&
			    (properties.sprite != Draw::kBackSurface)) {
				properties.sprite = -1;
				video->surface.reset();
				video->decoder->setSurfaceMemory();
				properties.x = properties.y = 0;
			} else {
				video->surface = _vm->_draw->_spritesArray[properties.sprite];
				if (properties.sprite == Draw::kFrontSurface)
					video->surface = _vm->_draw->_frontSurface;
				if (properties.sprite == Draw::kBackSurface)
					video->surface = _vm->_draw->_backSurface;

				video->decoder->setSurfaceMemory(video->surface->getData(),
						video->surface->getWidth(), video->surface->getHeight(), video->surface->getBPP());

				if (!ownSurf || (ownSurf && screenSize)) {
					if ((properties.x >= 0) || (properties.y >= 0)) {
						properties.x = (properties.x < 0) ? 0xFFFF : properties.x;
						properties.y = (properties.y < 0) ? 0xFFFF : properties.y;
					} else
						properties.x = properties.y = -1;
				} else
					properties.x = properties.y = 0;
			}

		} else {
			properties.sprite = -1;
			video->surface.reset();
			video->decoder->setSurfaceMemory();
			properties.x = properties.y = 0;
		}
	}

	video->decoder->setXY(properties.x, properties.y);

	if (primary)
		_needBlit = (properties.flags & kFlagUseBackSurfaceContent) && (properties.sprite == Draw::kFrontSurface);

	properties.hasSound = video->decoder->hasSound();

	if (!video->decoder->hasSound())
		video->decoder->setFrameRate(_vm->_util->getFrameRate());

	WRITE_VAR(7, video->decoder->getFrameCount());

	return slot;
}
コード例 #21
0
ファイル: videoplayer.cpp プロジェクト: Termimad/scummvm
bool VideoPlayer::playFrame(int slot, Properties &properties) {
	Video *video = getVideoBySlot(slot);
	if (!video)
		return false;

	bool primary = slot == 0;

	if (video->decoder->getCurFrame() != properties.startFrame) {

		if (properties.startFrame != -1) {
			// Seek into the middle of the video

			if (video->decoder->hasSound()) {
				// But there's sound

				if (properties.forceSeek) {
					// And we force seeking => Seek

					video->decoder->disableSound();
					video->decoder->seek(properties.startFrame + 1, SEEK_SET, true);
				}

			} else
				// No sound => We can safely seek
				video->decoder->seek(properties.startFrame + 1, SEEK_SET, true);

		} else {
			// Seek to the start => We can safely seek

			video->decoder->disableSound();
			video->decoder->seek(0, SEEK_SET, true);
			video->decoder->enableSound();
		}

	}

	if (video->decoder->getCurFrame() > properties.startFrame)
		// If the video is already beyond the wanted frame, skip
		return true;

	bool modifiedPal = false;

	if (primary) {
		// Pre-decoding palette and blitting, only for primary videos

		if ((properties.startFrame == properties.palFrame) ||
		    ((properties.startFrame == properties.endFrame) && (properties.palCmd == 8))) {

			modifiedPal = true;
			_vm->_draw->_applyPal = true;

			if (properties.palCmd >= 4)
				copyPalette(*video, properties.palStart, properties.palEnd);
		}

		if (modifiedPal && (properties.palCmd == 8) && (video->surface != _vm->_draw->_backSurface))
			_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);

		if (_needBlit)
			_vm->_draw->forceBlit();
	}

	const Graphics::Surface *surface = video->decoder->decodeNextFrame();

	WRITE_VAR(11, video->decoder->getCurFrame());

	uint32 ignoreBorder = 0;
	if (_woodruffCohCottWorkaround && (properties.startFrame == 31)) {
		// WORKAROUND: This frame mistakenly masks Coh Cott, making her vanish
		// To prevent that, we'll never draw that part
		ignoreBorder = 50;
	}

	if (surface && primary) {
		// Post-decoding palette and blitting, only for primary videos

		if (_needBlit)
			_vm->_draw->forceBlit(true);

		if (modifiedPal && (properties.palCmd == 16)) {
			if (video->surface == _vm->_draw->_backSurface)
				_vm->_draw->forceBlit();
			_vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0);
			_vm->_draw->_noInvalidated = true;
			_vm->_video->dirtyRectsAll();
		}

		if (video->decoder->hasPalette() && (properties.palCmd > 1)) {
			copyPalette(*video, properties.palStart, properties.palEnd);

			if (video->surface != _vm->_draw->_backSurface)
				_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
			else
				_vm->_draw->_applyPal = true;
		}

		const Common::List<Common::Rect> &dirtyRects = video->decoder->getDirtyRects();

		if (modifiedPal && (properties.palCmd == 8) && (video->surface == _vm->_draw->_backSurface))
			_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);

		if (video->surface == _vm->_draw->_backSurface) {

			for (Common::List<Common::Rect>::const_iterator rect = dirtyRects.begin(); rect != dirtyRects.end(); ++rect)
				_vm->_draw->invalidateRect(rect->left + ignoreBorder, rect->top, rect->right - 1, rect->bottom - 1);
			if (!video->live)
				_vm->_draw->blitInvalidated();

		} else if (video->surface == _vm->_draw->_frontSurface) {
			for (Common::List<Common::Rect>::const_iterator rect = dirtyRects.begin(); rect != dirtyRects.end(); ++rect)
				_vm->_video->dirtyRectsAdd(rect->left + ignoreBorder, rect->top, rect->right - 1, rect->bottom - 1);

		}

		if (!video->live && ((video->decoder->getCurFrame() - 1) == properties.startFrame))
			// Only retrace if we're playing the frame we actually want to play
			_vm->_video->retrace();

		int32 subtitle = video->decoder->getSubtitleIndex();
		if (subtitle != -1)
			_vm->_draw->printTotText(subtitle);

		if (modifiedPal && ((properties.palCmd == 2) || (properties.palCmd == 4)))
			_vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0);
	}

	if (primary && properties.waitEndFrame)
		checkAbort(*video, properties);

	if ((video->decoder->getCurFrame() - 1) < properties.startFrame)
		// The video played a frame we actually didn't want, so we have to adjust
		properties.startFrame--;

	return true;
}
コード例 #22
0
ファイル: inter_fascin.cpp プロジェクト: 33d/scummvm
void Inter_Fascination::oFascin_openWin() {
	int16 retVal, id;
	_vm->_game->_script->evalExpr(&id);
	retVal = _vm->_game->_script->readVarIndex();
	WRITE_VAR((retVal / 4), (int32) _vm->_draw->openWin(id));
}
コード例 #23
0
ファイル: inter_v7.cpp プロジェクト: Templier/scummvm-test
void Inter_v7::o7_draw0x0C() {
	WRITE_VAR(17, 0);
}
コード例 #24
0
ファイル: goblin_v2.cpp プロジェクト: 33d/scummvm
void Goblin_v2::movePathFind(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16 nextAct) {
	Mult::Mult_AnimData *animData = obj->pAnimData;

	animData->newCycle = _vm->_scenery->getAnimLayer(animData->animation, animData->layer)->framesCount;

	int16 gobX     = obj->goblinX;
	int16 gobY     = obj->goblinY;
	int16 destX    = obj->destX;
	int16 destY    = obj->destY;
	int16 gobDestX = obj->gobDestX;
	int16 gobDestY = obj->gobDestY;

	animData->destX = gobDestX;
	animData->destY = gobDestY;
	animData->order = gobY;

	Direction dir = kDirNone;

	if (animData->pathExistence == 1) {

		dir = _vm->_map->getDirection(gobX, gobY, destX, destY);
		if (dir == kDirNone)
			animData->pathExistence = 0;
		if ((gobX == gobDestX) && (gobY == gobDestY))
			animData->pathExistence = 4;

	} else if (animData->pathExistence == 3) {

		if ((gobX != gobDestX) || (gobY != gobDestY)) {

			if (_vm->_map->checkDirectPath(obj, gobX, gobY, gobDestX, gobDestY) != 1) {

				if ((gobX == destX) && (gobY == destY)) {

					if (obj->nearestWayPoint > obj->nearestDest) {
						_vm->_map->optimizePoints(obj, gobX, gobY);

						const WayPoint &wayPoint = _vm->_map->getWayPoint(obj->nearestWayPoint);

						destX = wayPoint.x;
						destY = wayPoint.y;

						if (_vm->_map->checkDirectPath(obj, gobX, gobY, destX, destY) == 3) {
							WRITE_VAR(56, 1);
							animData->pathExistence = 0;
						}
						if (obj->nearestWayPoint > obj->nearestDest)
							obj->nearestWayPoint--;
					} else if (obj->nearestWayPoint < obj->nearestDest) {
						_vm->_map->optimizePoints(obj, gobX, gobY);

						const WayPoint &wayPoint = _vm->_map->getWayPoint(obj->nearestWayPoint);

						destX = wayPoint.x;
						destY = wayPoint.y;

						if (_vm->_map->checkDirectPath(obj, gobX, gobY, destX, destY) == 3) {
							WRITE_VAR(56, 1);
							animData->pathExistence = 0;
						}
						if (obj->nearestWayPoint < obj->nearestDest)
							obj->nearestWayPoint++;
					} else {
						if ((_vm->_map->checkDirectPath(obj, gobX, gobY, gobDestX, gobDestY) == 3) &&
								(_vm->_map->getPass(gobDestX, gobDestY) != 0)) {

							const WayPoint &wayPoint = _vm->_map->getWayPoint(obj->nearestWayPoint);

							destX = wayPoint.x;
							destY = wayPoint.y;

							WRITE_VAR(56, 1);
						} else {
							animData->pathExistence = 1;
							destX = gobDestX;
							destY = gobDestY;
						}
					}

				}

			} else {
				destX = gobDestX;
				destY = gobDestY;
			}

			dir = _vm->_map->getDirection(gobX, gobY, destX, destY);

		} else {
			animData->pathExistence = 4;
			destX = gobDestX;
			destY = gobDestY;
		}

	}

	obj->goblinX   = gobX;
	obj->goblinY   = gobY;
	obj->destX     = destX;
	obj->destY     = destY;
	obj->gobDestX  = gobDestX;
	obj->gobDestY  = gobDestY;

	switch (dir) {
	case kDirNW:
		animData->nextState = 1;
		if (_vm->_map->getScreenWidth() == 640) {
			if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10)
				animData->nextState = 40;
			if (_vm->_map->getPass(obj->goblinX - 1, obj->goblinY - 2) != 10)
				animData->nextState = 1;
		}
		break;

	case kDirN:
		animData->nextState =
			(animData->curLookDir == 2) ? 2 : rotateState(animData->curLookDir, 2);
		if (_vm->_map->getScreenWidth() == 640) {
			if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10) {
				if      (_vm->_map->getPass(obj->goblinX - 1, obj->goblinY - 2) == 10)
					animData->nextState = 40;
				else if (_vm->_map->getPass(obj->goblinX + 1, obj->goblinY - 2) == 10)
					animData->nextState = 42;
				else
					animData->nextState = 2;
			}

			if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 20)
				animData->nextState = 38;
			if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 19)
				animData->nextState = 26;
		}
		break;

	case kDirNE:
		animData->nextState = 3;
		if (_vm->_map->getScreenWidth() == 640) {
			if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10)
				animData->nextState = 42;
			if (_vm->_map->getPass(obj->goblinX + 1, obj->goblinY - 2) != 10)
				animData->nextState = 3;
		}
		break;

	case kDirW:
		animData->nextState = rotateState(animData->curLookDir, 0);
		break;

	case kDirE:
		animData->nextState = rotateState(animData->curLookDir, 4);
		break;

	case kDirSW:
		animData->nextState = 7;
		if (_vm->_map->getScreenWidth() == 640) {
			if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10)
				animData->nextState = 41;
			if (_vm->_map->getPass(obj->goblinX - 1, obj->goblinY + 2) != 10)
				animData->nextState = 7;
		}
		break;

	case kDirS:
		animData->nextState =
			(animData->curLookDir == 6) ? 6 : rotateState(animData->curLookDir, 6);
		if (_vm->_map->getScreenWidth() == 640) {
			if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 20)
				animData->nextState = 39;
			if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 19)
				animData->nextState = 27;
		}
		break;

	case kDirSE:
		animData->nextState = 5;
		if (_vm->_map->getScreenWidth() == 640) {
			if (_vm->_map->getPass(obj->goblinX, obj->goblinY) == 10)
				animData->nextState = 43;
			if (_vm->_map->getPass(obj->goblinX + 1, obj->goblinY + 2) != 10)
				animData->nextState = 5;
		}
		break;

	default:
		if      (animData->curLookDir == 0)
			animData->nextState = 8;
		else if (animData->curLookDir == 2)
			animData->nextState = 29;
		else if (animData->curLookDir == 4)
			animData->nextState = 9;
		else if (animData->curLookDir == 6)
			animData->nextState = 28;
		break;
	}
}