diff options
author | johndoe123 | 2011-07-03 12:09:48 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:30:58 +0200 |
commit | 44ab81eab83189bfa0693fca564543227d423799 (patch) | |
tree | c95d048fa3f8983615703be025d57ee535c93f23 /engines | |
parent | 3c82668fe4267b34a9e3c7fe88f0d2a0fcfc4c4b (diff) | |
download | scummvm-rg350-44ab81eab83189bfa0693fca564543227d423799.tar.gz scummvm-rg350-44ab81eab83189bfa0693fca564543227d423799.tar.bz2 scummvm-rg350-44ab81eab83189bfa0693fca564543227d423799.zip |
NEVERHOOD: Start with the Screen class, also
- Move common headers used in modules to module.h so they don't have to be explicitly #included in each module header
- Clean up #includes
Diffstat (limited to 'engines')
-rw-r--r-- | engines/neverhood/module.h | 3 | ||||
-rw-r--r-- | engines/neverhood/module.mk | 1 | ||||
-rw-r--r-- | engines/neverhood/module1500.cpp | 2 | ||||
-rw-r--r-- | engines/neverhood/module1500.h | 2 | ||||
-rw-r--r-- | engines/neverhood/neverhood.cpp | 14 | ||||
-rw-r--r-- | engines/neverhood/neverhood.h | 8 | ||||
-rw-r--r-- | engines/neverhood/scene.cpp | 6 | ||||
-rw-r--r-- | engines/neverhood/screen.cpp | 88 | ||||
-rw-r--r-- | engines/neverhood/screen.h | 54 |
9 files changed, 157 insertions, 21 deletions
diff --git a/engines/neverhood/module.h b/engines/neverhood/module.h index 432a04c043..b59b532fad 100644 --- a/engines/neverhood/module.h +++ b/engines/neverhood/module.h @@ -27,6 +27,9 @@ #include "neverhood/neverhood.h" #include "neverhood/entity.h" +#include "neverhood/graphics.h" +#include "neverhood/palette.h" +#include "neverhood/screen.h" namespace Neverhood { diff --git a/engines/neverhood/module.mk b/engines/neverhood/module.mk index 709538e565..e51565f76b 100644 --- a/engines/neverhood/module.mk +++ b/engines/neverhood/module.mk @@ -13,6 +13,7 @@ MODULE_OBJS = \ resource.o \ resourceman.o \ scene.o \ + screen.o \ sprite.o # This module can be built as a plugin diff --git a/engines/neverhood/module1500.cpp b/engines/neverhood/module1500.cpp index f4c77948b4..97d125a45f 100644 --- a/engines/neverhood/module1500.cpp +++ b/engines/neverhood/module1500.cpp @@ -147,7 +147,7 @@ void Scene1501::update() { if (_countdown1 != 0) { _countdown1--; if (_countdown1 == 0) { - // TODO g_screen->clear(0); + _vm->_screen->clear(); _parentModule->sendMessage(0x1009, 0, this); } } else if ((_countdown2 != 0 && (--_countdown2 == 0)) || !_soundResource.isPlaying()) { diff --git a/engines/neverhood/module1500.h b/engines/neverhood/module1500.h index 66eef59073..e3633a0e85 100644 --- a/engines/neverhood/module1500.h +++ b/engines/neverhood/module1500.h @@ -28,8 +28,6 @@ #include "neverhood/neverhood.h" #include "neverhood/module.h" #include "neverhood/scene.h" -#include "neverhood/graphics.h" -#include "neverhood/palette.h" namespace Neverhood { diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp index ac89a3e658..4baff5eafa 100644 --- a/engines/neverhood/neverhood.cpp +++ b/engines/neverhood/neverhood.cpp @@ -20,28 +20,19 @@ * */ -#include "common/events.h" -#include "common/keyboard.h" #include "common/file.h" -#include "common/random.h" -#include "common/savefile.h" #include "common/config-manager.h" - #include "base/plugins.h" #include "base/version.h" - #include "graphics/cursorman.h" - #include "engines/util.h" - -#include "audio/mixer.h" - #include "neverhood/neverhood.h" #include "neverhood/blbarchive.h" #include "neverhood/gamemodule.h" #include "neverhood/graphics.h" #include "neverhood/resourceman.h" #include "neverhood/resource.h" +#include "neverhood/screen.h" namespace Neverhood { @@ -71,6 +62,8 @@ Common::Error NeverhoodEngine::run() { _isSaveAllowed = false; + _screen = new Screen(this); + _res = new ResourceMan(); _res->addArchive("a.blb"); _res->addArchive("c.blb"); @@ -179,6 +172,7 @@ Common::Error NeverhoodEngine::run() { delete _gameModule; delete _res; + delete _screen; debug("Ok."); diff --git a/engines/neverhood/neverhood.h b/engines/neverhood/neverhood.h index b261a087f0..c13ac517fb 100644 --- a/engines/neverhood/neverhood.h +++ b/engines/neverhood/neverhood.h @@ -29,11 +29,7 @@ #include "common/random.h" #include "common/savefile.h" #include "common/system.h" - #include "audio/mixer.h" - -#include "graphics/surface.h" - #include "engines/engine.h" namespace Neverhood { @@ -43,8 +39,9 @@ enum NeverhoodGameFeatures { struct NeverhoodGameDescription; -class ResourceMan; class GameModule; +class ResourceMan; +class Screen; struct GameState { int sceneNum; @@ -74,6 +71,7 @@ public: uint16 _buttonState; GameState _gameState; + Screen *_screen; ResourceMan *_res; GameModule *_gameModule; diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp index ccdae3a287..f1209318ec 100644 --- a/engines/neverhood/scene.cpp +++ b/engines/neverhood/scene.cpp @@ -39,13 +39,13 @@ Scene::Scene(NeverhoodEngine *vm, Module *parentModule, bool clearHitRects) // TODO _playerSprite = NULL; // TODO _mouseSprite = NULL; _palette = NULL; - // TODO _class300 = NULL; + // TODO _background = NULL; // TODO _field_8E = -1; if (clearHitRects) { // TODO g_Class700->setHitRects(NULL, 0); // TODO g_Class700->clear(); } - // TODO g_screen->setFps(24); + _vm->_screen->setFps(24); // TODO g_screen->hSmack = NULL; // TODO g_screen->field_24 = 0; // TODO g_screen->field_26 = 0; @@ -292,7 +292,7 @@ void Scene::smackerUpdate() { _messageHandlerCb = _savedMessageHandlerCb; if (_palette) _palette->usePalette(); - // TODO class300->restore(); + // TODO _background->restore(); // TODO g_screen->smackerPlayer = NULL; } #endif diff --git a/engines/neverhood/screen.cpp b/engines/neverhood/screen.cpp new file mode 100644 index 0000000000..4b531ca139 --- /dev/null +++ b/engines/neverhood/screen.cpp @@ -0,0 +1,88 @@ +/* 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 "graphics/palette.h" +#include "neverhood/screen.h" + +namespace Neverhood { + +Screen::Screen(NeverhoodEngine *vm) + : _vm(vm), _paletteData(NULL), _paletteChanged(false) { + + _ticks = _vm->_system->getMillis(); + + _backScreen = new Graphics::Surface(); + _backScreen->create(640, 480, Graphics::PixelFormat::createFormatCLUT8()); + +} + +Screen::~Screen() { + delete _backScreen; +} + +void Screen::wait() { +} + +void Screen::setFps(int fps) { + _frameDelay = 1000 / fps; +} + +int Screen::getFps() { + return 1000 / _frameDelay; +} + +void Screen::setPaletteData(byte *paletteData) { + _paletteChanged = true; + _paletteData = paletteData; +} + +void Screen::unsetPaletteData(byte *paletteData) { + if (_paletteData == paletteData) { + _paletteChanged = false; + _paletteData = NULL; + } +} + +void Screen::testPalette(byte *paletteData) { + if (_paletteData == paletteData) + _paletteChanged = true; +} + +void Screen::updatePalette() { + if (_paletteChanged && _paletteData) { + byte *tempPalette = new byte[768]; + for (int i = 0; i < 256; i++) { + tempPalette[i * 3 + 0] = _paletteData[i * 4 + 0]; + tempPalette[i * 3 + 1] = _paletteData[i * 4 + 1]; + tempPalette[i * 3 + 2] = _paletteData[i * 4 + 2]; + } + _vm->_system->getPaletteManager()->setPalette(tempPalette, 0, 256); + delete[] tempPalette; + _paletteChanged = false; + } +} + +void Screen::clear() { + memset(_backScreen->pixels, 0, _backScreen->pitch * _backScreen->h); +} + +} // End of namespace Neverhood diff --git a/engines/neverhood/screen.h b/engines/neverhood/screen.h new file mode 100644 index 0000000000..0e7ce3d7d6 --- /dev/null +++ b/engines/neverhood/screen.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_SCREEN_H +#define NEVERHOOD_SCREEN_H + +#include "graphics/surface.h" +#include "neverhood/neverhood.h" + +namespace Neverhood { + +class Screen { +public: + Screen(NeverhoodEngine *vm); + ~Screen(); + void wait(); + void setFps(int fps); + int getFps(); + void setPaletteData(byte *paletteData); + void unsetPaletteData(byte *paletteData); + void testPalette(byte *paletteData); + void updatePalette(); + void clear(); +protected: + NeverhoodEngine *_vm; + Graphics::Surface *_backScreen; + uint32 _ticks; + uint32 _frameDelay; + byte *_paletteData; + bool _paletteChanged; +}; + +} // End of namespace Neverhood + +#endif /* NEVERHOOD_SCREEN_H */ |