diff options
| -rw-r--r-- | engines/gob/pregob/pregob.cpp | 60 | ||||
| -rw-r--r-- | engines/gob/pregob/pregob.h | 17 | 
2 files changed, 76 insertions, 1 deletions
| diff --git a/engines/gob/pregob/pregob.cpp b/engines/gob/pregob/pregob.cpp index ab47adaac6..aea290214c 100644 --- a/engines/gob/pregob/pregob.cpp +++ b/engines/gob/pregob/pregob.cpp @@ -21,15 +21,73 @@   */  #include "gob/gob.h" +#include "gob/global.h" +#include "gob/util.h" +#include "gob/palanim.h" +#include "gob/draw.h" +#include "gob/video.h"  #include "gob/pregob/pregob.h"  namespace Gob { -PreGob::PreGob(GobEngine *vm) : _vm(vm) { +PreGob::PreGob(GobEngine *vm) : _vm(vm), _fadedOut(false) {  }  PreGob::~PreGob() {  } +void PreGob::fadeOut() { +	if (_fadedOut || _vm->shouldQuit()) +		return; + +	// Fade to black +	_vm->_palAnim->fade(0, 0, 0); + +	_fadedOut = true; +} + +void PreGob::fadeIn() { +	if (!_fadedOut || _vm->shouldQuit()) +		return; + +	// Fade to palette +	_vm->_draw->blitInvalidated(); +	_vm->_palAnim->fade(_vm->_global->_pPaletteDesc, 0, 0); +	_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 0, 0, 319, 199); + +	_fadedOut = false; +} + +void PreGob::clearScreen() { +	_vm->_draw->_backSurface->clear(); +	_vm->_draw->dirtiedRect(_vm->_draw->_backSurface, 0, 0, 319, 199); +	_vm->_draw->blitInvalidated(); +	_vm->_video->retrace(); +} + +void PreGob::initScreen() { +	_vm->_util->setFrameRate(15); + +	_fadedOut = true; + +	_vm->_draw->initScreen(); + +	_vm->_draw->_backSurface->clear(); +	_vm->_util->clearPalette(); + +	_vm->_draw->forceBlit(); +	_vm->_video->retrace(); + +	_vm->_util->processInput(); +} + +void PreGob::setPalette(const byte *palette, uint16 size) { +	memcpy(_vm->_draw->_vgaPalette, palette, 3 * size); + +	// If we didn't fade out prior, immediately set the palette +	if (!_fadedOut) +		_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); +} +  } // End of namespace Gob diff --git a/engines/gob/pregob/pregob.h b/engines/gob/pregob/pregob.h index e77e0ba17b..6418d6fd8a 100644 --- a/engines/gob/pregob/pregob.h +++ b/engines/gob/pregob/pregob.h @@ -35,7 +35,24 @@ public:  	virtual void run() = 0;  protected: +	void initScreen(); ///< Initialize the game screen. + +	void fadeOut(); ///< Fade to black. +	void fadeIn();  ///< Fade to the current palette. + +	void clearScreen(); + +	/** Change the palette. +	 * +	 *  @param palette The palette to change to. +	 *  @param size Size of the palette in colors. +	 */ +	void setPalette(const byte *palette, uint16 size); ///< Change the palette +  	GobEngine *_vm; + +private: +	bool _fadedOut; ///< Did we fade out?  };  } // End of namespace Gob | 
