diff options
| author | johndoe123 | 2011-07-04 17:58:38 +0000 | 
|---|---|---|
| committer | Willem Jan Palenstijn | 2013-05-08 20:30:58 +0200 | 
| commit | 21eb88053caa4cc7167f81dba9afc7f0ef89996d (patch) | |
| tree | bbc1f3e645a55c3dda70bfdbbe3ab075e4e0f13b /engines | |
| parent | bd1749863e45cde53707d0ae38b28825bc0dba2e (diff) | |
| download | scummvm-rg350-21eb88053caa4cc7167f81dba9afc7f0ef89996d.tar.gz scummvm-rg350-21eb88053caa4cc7167f81dba9afc7f0ef89996d.tar.bz2 scummvm-rg350-21eb88053caa4cc7167f81dba9afc7f0ef89996d.zip  | |
NEVERHOOD: Implement SmackerScene, SmackerPlayer and related stuff
- The intro video after the logo screens is now played (still needs better sync)
Diffstat (limited to 'engines')
| -rw-r--r-- | engines/neverhood/blbarchive.cpp | 5 | ||||
| -rw-r--r-- | engines/neverhood/blbarchive.h | 3 | ||||
| -rw-r--r-- | engines/neverhood/gamemodule.cpp | 2 | ||||
| -rw-r--r-- | engines/neverhood/module.mk | 2 | ||||
| -rw-r--r-- | engines/neverhood/module1500.cpp | 10 | ||||
| -rw-r--r-- | engines/neverhood/module1500.h | 1 | ||||
| -rw-r--r-- | engines/neverhood/neverhood.cpp | 4 | ||||
| -rw-r--r-- | engines/neverhood/palette.cpp | 7 | ||||
| -rw-r--r-- | engines/neverhood/palette.h | 1 | ||||
| -rw-r--r-- | engines/neverhood/resourceman.cpp | 5 | ||||
| -rw-r--r-- | engines/neverhood/resourceman.h | 1 | ||||
| -rw-r--r-- | engines/neverhood/scene.cpp | 5 | ||||
| -rw-r--r-- | engines/neverhood/scene.h | 4 | ||||
| -rw-r--r-- | engines/neverhood/screen.cpp | 22 | ||||
| -rw-r--r-- | engines/neverhood/screen.h | 3 | ||||
| -rw-r--r-- | engines/neverhood/smackerplayer.cpp | 183 | ||||
| -rw-r--r-- | engines/neverhood/smackerplayer.h | 75 | ||||
| -rw-r--r-- | engines/neverhood/smackerscene.cpp | 127 | ||||
| -rw-r--r-- | engines/neverhood/smackerscene.h | 54 | 
19 files changed, 499 insertions, 15 deletions
diff --git a/engines/neverhood/blbarchive.cpp b/engines/neverhood/blbarchive.cpp index 4259be33f7..3138b9102d 100644 --- a/engines/neverhood/blbarchive.cpp +++ b/engines/neverhood/blbarchive.cpp @@ -108,4 +108,9 @@ byte *BlbArchive::getEntryExtData(uint index) {  	return _extData && entry.extDataOfs != 0 ? &_extData[entry.extDataOfs - 1] : NULL;  } +Common::SeekableReadStream *BlbArchive::createStream(uint index) { +	const BlbArchiveEntry &entry = _entries[index]; +	return new Common::SeekableSubReadStream(&_fd, entry.offset, entry.offset + entry.diskSize); +} +  } // End of namespace Neverhood diff --git a/engines/neverhood/blbarchive.h b/engines/neverhood/blbarchive.h index 3c373ccc96..ddb3f0196b 100644 --- a/engines/neverhood/blbarchive.h +++ b/engines/neverhood/blbarchive.h @@ -25,6 +25,8 @@  #include "common/array.h"  #include "common/file.h" +#include "common/stream.h" +#include "common/substream.h"  #include "neverhood/neverhood.h"  namespace Neverhood { @@ -58,6 +60,7 @@ public:  	uint32 getSize(uint index) { return _entries[index].size; }  	BlbArchiveEntry *getEntry(uint index) { return &_entries[index]; }  	uint getCount() { return _entries.size(); } +	Common::SeekableReadStream *createStream(uint index);  private:  	Common::File _fd;  	Common::Array<BlbArchiveEntry> _entries; diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp index e46d23c420..3f4ad4b536 100644 --- a/engines/neverhood/gamemodule.cpp +++ b/engines/neverhood/gamemodule.cpp @@ -102,7 +102,7 @@ void GameModule::updateModule1500() {  		_done = false;  		delete _childObject;  		_childObject = NULL; -		debug("Done..."); +		error("Done...");  		// TODO createModule1000();  		// TODO _childObject->handleUpdate();  	} diff --git a/engines/neverhood/module.mk b/engines/neverhood/module.mk index cc7f9e1d0d..8eb1951543 100644 --- a/engines/neverhood/module.mk +++ b/engines/neverhood/module.mk @@ -15,6 +15,8 @@ MODULE_OBJS = \  	resourceman.o \  	scene.o \  	screen.o \ +	smackerscene.o \ +	smackerplayer.o \  	sprite.o  # This module can be built as a plugin diff --git a/engines/neverhood/module1500.cpp b/engines/neverhood/module1500.cpp index c3c0864a59..95b3925245 100644 --- a/engines/neverhood/module1500.cpp +++ b/engines/neverhood/module1500.cpp @@ -92,8 +92,14 @@ void Module1500::createScene1502() {  void Module1500::createScene1503() {  	debug("createScene1503"); -	// TODO: This uses the MultiSmackerPlayer -	// Game will crash now... +	SmackerScene *smackerScene; +	_parentModule->sendMessage(0x0800, 0, this); +	_vm->gameState().sceneNum = 2; +	smackerScene = new SmackerScene(_vm, this, true, true, true); +	smackerScene->setFileHash(0x001A0005); +	smackerScene->nextVideo(); +	_childObject = smackerScene; +	SetUpdateHandler(&Module1500::update);  }  void Module1500::createScene1504() { diff --git a/engines/neverhood/module1500.h b/engines/neverhood/module1500.h index e3633a0e85..87b2a0b9ae 100644 --- a/engines/neverhood/module1500.h +++ b/engines/neverhood/module1500.h @@ -28,6 +28,7 @@  #include "neverhood/neverhood.h"  #include "neverhood/module.h"  #include "neverhood/scene.h" +#include "neverhood/smackerscene.h"  namespace Neverhood { diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp index 9019409193..650681289a 100644 --- a/engines/neverhood/neverhood.cpp +++ b/engines/neverhood/neverhood.cpp @@ -165,13 +165,13 @@ Common::Error NeverhoodEngine::run() {  			}  		} -		debug("millis %d", _system->getMillis());		 +		//debug("millis %d", _system->getMillis());		  		_gameModule->handleUpdate();  		_gameModule->draw();  		_screen->wait();  		_screen->update(); -		debug("---------------------------------------"); +		//debug("---------------------------------------");  	} diff --git a/engines/neverhood/palette.cpp b/engines/neverhood/palette.cpp index bfabf8998a..e186d3814f 100644 --- a/engines/neverhood/palette.cpp +++ b/engines/neverhood/palette.cpp @@ -82,6 +82,13 @@ void Palette::addPalette(uint32 fileHash, int toIndex, int count, int fromIndex)  	_vm->_screen->testPalette(_palette);  } +void Palette::copyPalette(const byte *palette, int toIndex, int count, int fromIndex) { +	if (toIndex + count > 256) +		count = 256 - toIndex; +	memcpy(_palette + toIndex * 4, palette + fromIndex * 4, count * 4);		 +	_vm->_screen->testPalette(_palette); +} +  void Palette::startFadeToBlack(int counter) {  	debug("Palette::startFadeToBlack(%d)", counter);  	if (counter == 0) diff --git a/engines/neverhood/palette.h b/engines/neverhood/palette.h index 752ae3aedb..e3d95aa7f6 100644 --- a/engines/neverhood/palette.h +++ b/engines/neverhood/palette.h @@ -42,6 +42,7 @@ public:  	void usePalette();  	void addPalette(const char *filename, int toIndex, int count, int fromIndex);  	void addPalette(uint32 fileHash, int toIndex, int count, int fromIndex); +	void copyPalette(const byte *palette, int toIndex, int count, int fromIndex);  	void startFadeToBlack(int counter);  	void startFadeToWhite(int counter);  protected: diff --git a/engines/neverhood/resourceman.cpp b/engines/neverhood/resourceman.cpp index 59e3fad14a..28f0994cb1 100644 --- a/engines/neverhood/resourceman.cpp +++ b/engines/neverhood/resourceman.cpp @@ -164,4 +164,9 @@ void ResourceMan::freeResource(Resource *resource) {  	resource->data = NULL;  } +Common::SeekableReadStream *ResourceMan::createStream(uint32 fileHash) { +	ResourceFileEntry *entry = findEntry(fileHash); +	return _archives[entry->archiveIndex]->createStream(entry->entryIndex); +} +  } // End of namespace Neverhood diff --git a/engines/neverhood/resourceman.h b/engines/neverhood/resourceman.h index 0dd70e13a2..22614401f8 100644 --- a/engines/neverhood/resourceman.h +++ b/engines/neverhood/resourceman.h @@ -67,6 +67,7 @@ public:  	byte *loadResource(int resourceHandle, bool moveToFront = false);  	void unloadResource(int resourceHandle);  	void freeResource(Resource *resource); +	Common::SeekableReadStream *createStream(uint32 fileHash);  private:  	Common::Array<BlbArchive*> _archives;  	Common::Array<ResourceFileEntry> _entries; diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp index 6c3aae1e29..a73b45b9f7 100644 --- a/engines/neverhood/scene.cpp +++ b/engines/neverhood/scene.cpp @@ -78,15 +78,14 @@ Scene::~Scene() {  }  void Scene::draw() { -	debug("Scene::draw()"); -	//**ALL TODO  	if (_smackerPlayer) {  		if (_surfaceFlag) {  			// TODO g_screen->resetDirtyRects();  			// TODO g_screen->copyDirtyRects();  			// TODO g_screen->addDirtyRects();  		} -		// TODO _smackerPlayer->_surface->draw(); +		if (_smackerPlayer->getSurface()) +			_smackerPlayer->getSurface()->draw();  	} else {  		if (_surfaceFlag) {  			// TODO g_screen->copyDirtyRects(); diff --git a/engines/neverhood/scene.h b/engines/neverhood/scene.h index c64c2bfbef..405a528143 100644 --- a/engines/neverhood/scene.h +++ b/engines/neverhood/scene.h @@ -30,6 +30,7 @@  #include "neverhood/graphics.h"  #include "neverhood/module.h"  #include "neverhood/palette.h" +#include "neverhood/smackerplayer.h"  #include "neverhood/sprite.h"  namespace Neverhood { @@ -39,9 +40,6 @@ struct MessageListItem {  	uint32 messageValue;  }; -class SmackerPlayer { // DUMMY! -}; -  class Scene : public Entity {  public:  	Scene(NeverhoodEngine *vm, Module *parentModule, bool clearHitRects); diff --git a/engines/neverhood/screen.cpp b/engines/neverhood/screen.cpp index 807e241ccd..68f611050d 100644 --- a/engines/neverhood/screen.cpp +++ b/engines/neverhood/screen.cpp @@ -78,7 +78,6 @@ void Screen::testPalette(byte *paletteData) {  void Screen::updatePalette() {  	if (_paletteChanged && _paletteData) { -		debug("Screen::updatePalette() Set palette");  		byte *tempPalette = new byte[768];  		for (int i = 0; i < 256; i++) {  			tempPalette[i * 3 + 0] = _paletteData[i * 4 + 0]; @@ -95,7 +94,7 @@ void Screen::clear() {  	memset(_backScreen->pixels, 0, _backScreen->pitch * _backScreen->h);  } -void Screen::drawSurface2(Graphics::Surface *surface, NDrawRect &drawRect, NRect &clipRect) { +void Screen::drawSurface2(const Graphics::Surface *surface, NDrawRect &drawRect, NRect &clipRect) {  	int16 destX, destY;  	NRect ddRect; @@ -128,7 +127,7 @@ void Screen::drawSurface2(Graphics::Surface *surface, NDrawRect &drawRect, NRect  	debug("draw: x = %d; y = %d; (%d, %d, %d, %d)", destX, destY, ddRect.x1, ddRect.y1, ddRect.x2, ddRect.y2); -	byte *source = (byte*)surface->getBasePtr(ddRect.x1, ddRect.y1); +	const byte *source = (const byte*)surface->getBasePtr(ddRect.x1, ddRect.y1);  	byte *dest = (byte*)_backScreen->getBasePtr(destX, destY);  	int width = ddRect.x2 - ddRect.x1;  	int height = ddRect.y2 - ddRect.y1; @@ -157,5 +156,22 @@ void Screen::drawSurface2(Graphics::Surface *surface, NDrawRect &drawRect, NRect  } +void Screen::drawDoubleSurface2(const Graphics::Surface *surface, NDrawRect &drawRect) { + +	const byte *source = (const byte*)surface->getBasePtr(0, 0); +	byte *dest = (byte*)_backScreen->getBasePtr(drawRect.x, drawRect.y); +	 +	for (int16 yc = 0; yc < surface->h; yc++) { +		byte *row = dest; +		for (int16 xc = 0; xc < surface->w; xc++) { +			*row++ = *source; +			*row++ = *source++; +		} +		memcpy(dest + _backScreen->pitch, dest, surface->w * 2); +		dest += _backScreen->pitch; +		dest += _backScreen->pitch; +	} + +}  } // End of namespace Neverhood diff --git a/engines/neverhood/screen.h b/engines/neverhood/screen.h index e25b3b5dba..fc56a18ea6 100644 --- a/engines/neverhood/screen.h +++ b/engines/neverhood/screen.h @@ -42,7 +42,8 @@ public:  	void testPalette(byte *paletteData);  	void updatePalette();  	void clear(); -	void drawSurface2(Graphics::Surface *surface, NDrawRect &drawRect, NRect &clipRect); +	void drawSurface2(const Graphics::Surface *surface, NDrawRect &drawRect, NRect &clipRect); +	void drawDoubleSurface2(const Graphics::Surface *surface, NDrawRect &drawRect);  protected:  	NeverhoodEngine *_vm;  	Graphics::Surface *_backScreen; diff --git a/engines/neverhood/smackerplayer.cpp b/engines/neverhood/smackerplayer.cpp new file mode 100644 index 0000000000..c914b42482 --- /dev/null +++ b/engines/neverhood/smackerplayer.cpp @@ -0,0 +1,183 @@ +/* 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. + * + */ + +#include "neverhood/smackerplayer.h" +#include "neverhood/palette.h" +#include "neverhood/resourceman.h" +#include "neverhood/scene.h" + +namespace Neverhood { + +// SmackerSurface + +SmackerSurface::SmackerSurface(NeverhoodEngine *vm) +	: BaseSurface(vm, 0, 0, 0), _smackerFrame(NULL) { +} + +void SmackerSurface::draw() { +	if (_smackerFrame && _visible && _drawRect.width > 0 && _drawRect.height > 0) { +		_vm->_screen->drawSurface2(_smackerFrame, _drawRect, _clipRect); +	} +} + +void SmackerSurface::setSmackerFrame(const Graphics::Surface *smackerFrame) { +	_drawRect.x = 0; +	_drawRect.y = 0; +	_drawRect.width = smackerFrame->w; +	_drawRect.height = smackerFrame->h; +	// TODO: Check if _sysRect is needed at all in the reimplementation... +	_sysRect.x = 0; +	_sysRect.y = 0; +	_sysRect.width = (smackerFrame->w + 3) & 0xFFFC; // align by 4 bytes +	_sysRect.height = smackerFrame->h; +	_smackerFrame = smackerFrame; +} + +// SmackerDoubleSurface + +SmackerDoubleSurface::SmackerDoubleSurface(NeverhoodEngine *vm) +	: SmackerSurface(vm) { +} + +void SmackerDoubleSurface::draw() { +	if (_smackerFrame && _visible && _drawRect.width > 0 && _drawRect.height > 0) { +		_vm->_screen->drawDoubleSurface2(_smackerFrame, _drawRect); +	} +} + +// SmackerPlayer + +SmackerPlayer::SmackerPlayer(NeverhoodEngine *vm, Scene *scene, uint32 fileHash, bool doubleSurface, bool flag) +	: Entity(vm, 0), _scene(scene), _doubleSurface(doubleSurface), _dirtyFlag(false), _flag2(false), +	_palette(NULL), _smackerDecoder(NULL), _smackerSurface(NULL), _stream(NULL) { + +	SetUpdateHandler(&SmackerPlayer::update); +	open(fileHash, flag); +} + +SmackerPlayer::~SmackerPlayer() { +	close(); +} + +void SmackerPlayer::open(uint32 fileHash, bool flag1) { +	debug("SmackerPlayer::open(%08X)", fileHash); +	 +	_flag1 = flag1; + +	close(); + +	_stream = _vm->_res->createStream(fileHash); + +	// TODO: _flag1 stuff + +	_smackerDecoder = new Video::SmackerDecoder(_vm->_mixer); +	_smackerDecoder->loadStream(_stream); +	 +	_palette = new Palette(_vm); +	_palette->usePalette(); +	 +} + +void SmackerPlayer::close() { +	delete _smackerDecoder; +	delete _palette; +	// NOTE: The SmackerDecoder deletes the _stream +	delete _smackerSurface; +	_smackerDecoder = NULL; +	_palette = NULL; +	_stream = NULL; +	_smackerSurface = NULL; +} + +void SmackerPlayer::gotoFrame(uint frameNumber) { +} + +uint SmackerPlayer::getStatus() { +	return 0; +} + +void SmackerPlayer::update() { + +	if (!_smackerDecoder) +		return; + +	if (_dirtyFlag) { +		// TODO _vm->_screen->resetDirtyRects(); +		_dirtyFlag = false; +	} + +	if (!_smackerDecoder->endOfVideo()) { + +		const Graphics::Surface *smackerFrame = _smackerDecoder->decodeNextFrame(); + +		if (!_smackerSurface) { +			if (_doubleSurface) { +				// TODO: Use SmackerDoubleSurface +				_smackerSurface = new SmackerDoubleSurface(_vm); +				_smackerSurface->getDrawRect().x = 320 - _smackerDecoder->getWidth(); +				_smackerSurface->getDrawRect().y = 240 - _smackerDecoder->getHeight(); +				// TODO DoubleDrawSurface.field_28 = false; +				_smackerSurface->setSmackerFrame(smackerFrame); +			} else { +				_smackerSurface = new SmackerSurface(_vm); +				_smackerSurface->getDrawRect().x = (640 - _smackerDecoder->getWidth()) / 2; +				_smackerSurface->getDrawRect().y = (480 - _smackerDecoder->getHeight()) / 2; +				_smackerSurface->setSmackerFrame(smackerFrame); +			} +		} +		 +		if (_doubleSurface) { +			// TODO +		} + +		// TODO _vm->_screen->_skipUpdate = true; +		_dirtyFlag = true; + +		if (_smackerDecoder->hasDirtyPalette()) { +			updatePalette(); +		} + +		if (_smackerDecoder->endOfVideo() && !_flag1) { +			if (_scene) { +				_scene->sendMessage(0x3002, 0, this); +			} +			_flag2 = true; +		} else { +			_flag2 = false; +		} +		 +	} + +} + +void SmackerPlayer::updatePalette() { +	byte tempPalette[1024]; +	const byte *smackerPalette = _smackerDecoder->getPalette(); +	for (int i = 0; i < 256; i++) { +		tempPalette[i * 4 + 0] = smackerPalette[i * 3 + 0]; +		tempPalette[i * 4 + 1] = smackerPalette[i * 3 + 1]; +		tempPalette[i * 4 + 2] = smackerPalette[i * 3 + 2]; +	} +	_palette->copyPalette(tempPalette, 0, 256, 0); +} + +} // End of namespace Neverhood diff --git a/engines/neverhood/smackerplayer.h b/engines/neverhood/smackerplayer.h new file mode 100644 index 0000000000..d923bbdf6b --- /dev/null +++ b/engines/neverhood/smackerplayer.h @@ -0,0 +1,75 @@ +/* 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. + * + */ + +#ifndef NEVERHOOD_SMACKERPLAYER_H +#define NEVERHOOD_SMACKERPLAYER_H + +#include "video/smk_decoder.h" +#include "neverhood/neverhood.h" +#include "neverhood/entity.h" + +namespace Neverhood { + +class Scene; +class Palette; + +class SmackerSurface : public BaseSurface { +public: +	SmackerSurface(NeverhoodEngine *vm); +	virtual void draw(); +	void setSmackerFrame(const Graphics::Surface *smackerFrame); +protected: +	const Graphics::Surface *_smackerFrame; +}; + +class SmackerDoubleSurface : public SmackerSurface { +public: +	SmackerDoubleSurface(NeverhoodEngine *vm); +	virtual void draw(); +}; + +class SmackerPlayer : public Entity { +public: +	SmackerPlayer(NeverhoodEngine *vm, Scene *scene, uint32 fileHash, bool doubleSurface, bool flag); +	~SmackerPlayer(); +	BaseSurface *getSurface() { return _smackerSurface; } +	void open(uint32 fileHash, bool flag1); +	void close(); +	void gotoFrame(uint frameNumber); +	uint getStatus(); +protected: +	Scene *_scene; +	Palette *_palette; +	Video::SmackerDecoder *_smackerDecoder; +	SmackerSurface *_smackerSurface; +	bool _doubleSurface; +	Common::SeekableReadStream *_stream; +	bool _flag1; +	bool _flag2; +	bool _dirtyFlag; +	void update(); +	void updatePalette(); +}; + +} // End of namespace Neverhood + +#endif /* NEVERHOOD_SMACKERPLAYER_H */ diff --git a/engines/neverhood/smackerscene.cpp b/engines/neverhood/smackerscene.cpp new file mode 100644 index 0000000000..f3ee5775bc --- /dev/null +++ b/engines/neverhood/smackerscene.cpp @@ -0,0 +1,127 @@ +/* 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. + * + */ + +#include "neverhood/smackerscene.h" + +namespace Neverhood { + +SmackerScene::SmackerScene(NeverhoodEngine *vm, Module *parentModule, bool doubleSurface, bool flag1, bool canAbort) +	: Scene(vm, parentModule, true), _doubleSurface(doubleSurface), _flag1(flag1), _canAbort(canAbort), _fieldDF(false), +	_fileHashListIndex(-1), _fileHashList(NULL), _playNextVideoFlag(false) { + +	debug("SmackerScene::SmackerScene(%d, %d, %d)", doubleSurface, flag1, canAbort); + +	// NOTE: Merged from SmackerScene::init, maybe split again if needed (incl. parameter flags) +	 +	/* TODO +	if (_vm->getGlobalVarValue(0x06C02850)) { +		_flag1 = true; +		_canAbort = true; +	} +	*/ +	 +	if (_doubleSurface) { +		_vm->_screen->clear(); +	} + +	_fileHash[0] = 0;  +	_fileHash[1] = 0; + +	SetUpdateHandler(&SmackerScene::update); +	SetMessageHandler(&SmackerScene::handleMessage); + +} + +SmackerScene::~SmackerScene() { + +} + +void SmackerScene::setFileHash(uint32 fileHash) { +	debug("SmackerScene::setFileHash(%08X)", fileHash); +	_fileHash[0] = fileHash; +	_fileHashList = _fileHash; +} + +void SmackerScene::setFileHashList(uint32 *fileHashList) { +	debug("SmackerScene::setFileHashList(...)"); +	_fileHashList = fileHashList; +} + +void SmackerScene::nextVideo() { +	debug("SmackerScene::nextVideo()"); + +	_fileHashListIndex++; +	 +	if (_fileHashList && _fileHashList[_fileHashListIndex] != 0) { +		uint32 smackerFileHash = _fileHashList[_fileHashListIndex]; +		if (_vm->_res->getResourceTypeByHash(smackerFileHash) != 10) { +			// Not a Smacker file +			_parentModule->sendMessage(0x1009, 0, this); +			return; +		} +		// TODO _fieldDF = getGlobalSubVarValue(0x00800410, smackerFileHash); +		if (!_fieldDF) { +			// TODO setGlobalSubVarValue(0x00800410, smackerFileHash) = 1; +		} +		if (_fileHashListIndex == 0) { +			_smackerPlayer = new SmackerPlayer(_vm, this, smackerFileHash, _doubleSurface, false); +			addEntity(_smackerPlayer); +			addSurface(_smackerPlayer->getSurface()); +			// TODO? Screen.hSmack = _smackerPlayer; +		} else { +			_smackerPlayer->open(smackerFileHash, false); +		} +	} else { +		_parentModule->sendMessage(0x1009, 0, this); +	} + + +} + +void SmackerScene::update() { +	if (_playNextVideoFlag) { +		nextVideo(); +		_playNextVideoFlag = false; +	} +	Scene::update(); +} + +uint32 SmackerScene::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { +	uint32 messageResult = Scene::handleMessage(messageNum, param, sender); +	switch (messageNum) { +	case 0x0009: +		if ((_fieldDF && _flag1) || (_canAbort && _flag1)) +			_playNextVideoFlag = true; +		break; +	case 0x000C: +		if (_canAbort) { +			_parentModule->sendMessage(0x1009, 0, this); +		} +		break; +	case 0x3002: +		_playNextVideoFlag = true; +		break; +	} +	return messageResult; +} + +} // End of namespace Neverhood diff --git a/engines/neverhood/smackerscene.h b/engines/neverhood/smackerscene.h new file mode 100644 index 0000000000..b3c354c44a --- /dev/null +++ b/engines/neverhood/smackerscene.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +#ifndef NEVERHOOD_SMACKERSCENE_H +#define NEVERHOOD_SMACKERSCENE_H + +#include "neverhood/neverhood.h" +#include "neverhood/resourceman.h" +#include "neverhood/scene.h" + +namespace Neverhood { + +class SmackerScene : public Scene { +public: +	SmackerScene(NeverhoodEngine *vm, Module *parentModule, bool doubleSurface, bool flag1, bool canAbort); +	virtual ~SmackerScene(); +	void setFileHash(uint32 fileHash); +	void setFileHashList(uint32 *fileHashList); +	void nextVideo(); +protected: +	bool _doubleSurface; +	bool _flag1; +	bool _canAbort; +	bool _fieldDF; +	bool _playNextVideoFlag; +	int _fileHashListIndex; +	uint32 *_fileHashList; +	uint32 _fileHash[2]; +	void update(); +	uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); +}; + +} // End of namespace Neverhood + +#endif /* NEVERHOOD_SMACKERSCENE_H */  | 
