diff options
author | Kamil Zbróg | 2013-10-13 22:17:39 +0100 |
---|---|---|
committer | Kamil Zbróg | 2013-10-13 22:17:39 +0100 |
commit | dce5c876c5faa7577e8e6cdb47a8a3f071c62db8 (patch) | |
tree | 47ad814e085e52b76a010ae77ca882b4cda9b119 /engines | |
parent | fb2627569e03f3a1f51d7619db381253b30b9a0b (diff) | |
download | scummvm-rg350-dce5c876c5faa7577e8e6cdb47a8a3f071c62db8.tar.gz scummvm-rg350-dce5c876c5faa7577e8e6cdb47a8a3f071c62db8.tar.bz2 scummvm-rg350-dce5c876c5faa7577e8e6cdb47a8a3f071c62db8.zip |
PRINCE: graphic routines moved to separate file
Diffstat (limited to 'engines')
-rw-r--r-- | engines/prince/graphics.cpp | 34 | ||||
-rw-r--r-- | engines/prince/graphics.h | 58 | ||||
-rw-r--r-- | engines/prince/mhwanh.cpp | 2 | ||||
-rw-r--r-- | engines/prince/module.mk | 1 | ||||
-rw-r--r-- | engines/prince/prince.cpp | 35 | ||||
-rw-r--r-- | engines/prince/prince.h | 15 |
6 files changed, 114 insertions, 31 deletions
diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp new file mode 100644 index 0000000000..2d26dc0443 --- /dev/null +++ b/engines/prince/graphics.cpp @@ -0,0 +1,34 @@ +#include "prince/graphics.h" + +#include "prince/prince.h" + +#include "graphics/palette.h" + +namespace Prince { + +GraphicsMan::GraphicsMan(PrinceEngine *vm) : _vm(vm), _changed(false) +{ + initGraphics(640, 480, true); +} + +void GraphicsMan::update() +{ + if (_changed) + { + _vm->_system->copyRectToScreen((byte*)_roomBackground->getBasePtr(0,0), 640, 0, 0, 640, 480); + + _vm->_system->updateScreen(); + } +} + +void GraphicsMan::setPalette(const byte *palette) +{ + _vm->_system->getPaletteManager()->setPalette(palette, 0, 256); +} + +void GraphicsMan::change() +{ + _changed = true; +} + +} diff --git a/engines/prince/graphics.h b/engines/prince/graphics.h new file mode 100644 index 0000000000..3599cbc346 --- /dev/null +++ b/engines/prince/graphics.h @@ -0,0 +1,58 @@ +/* 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 PRINCE_GRAPHICS_H +#define PRINCE_GRAPHICS_H + +#include "graphics/surface.h" + + +namespace Prince { + +class PrinceEngine; + +class GraphicsMan +{ +public: + GraphicsMan(PrinceEngine *vm); + + void update(); + + void change(); + + void setPalette(const byte *palette); + + Graphics::Surface *_backScreen; + const Graphics::Surface *_roomBackground; + +private: + + PrinceEngine *_vm; + + bool _changed; + byte _palette[3 * 256]; + Graphics::Surface *_frontScreen; +}; + +} + +#endif diff --git a/engines/prince/mhwanh.cpp b/engines/prince/mhwanh.cpp index 4ce7beded9..5ad39313a0 100644 --- a/engines/prince/mhwanh.cpp +++ b/engines/prince/mhwanh.cpp @@ -42,7 +42,7 @@ void MhwanhDecoder::destroy() if (_surface) { _surface->free(); - delete _surface; _surface = 0; + _surface = 0; } delete [] _palette; _palette = 0; diff --git a/engines/prince/module.mk b/engines/prince/module.mk index e4a792f84d..8997ee1daa 100644 --- a/engines/prince/module.mk +++ b/engines/prince/module.mk @@ -1,6 +1,7 @@ MODULE := engines/prince
MODULE_OBJS = \
+ graphics.o \
mhwanh.o \
detection.o \
font.o \
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 2791bda86c..29451c8e66 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
+
#include "common/scummsys.h"
#include "common/config-manager.h"
@@ -45,6 +46,7 @@ #include "prince/prince.h"
#include "prince/font.h"
#include "prince/mhwanh.h"
+#include "prince/graphics.h"
namespace Prince {
@@ -61,7 +63,7 @@ PrinceEngine::~PrinceEngine() { Common::Error PrinceEngine::run() {
- initGraphics(640, 480, true);
+ _graph = new GraphicsMan(this);
const Common::FSNode gameDataDir(ConfMan.get("path"));
@@ -81,20 +83,21 @@ Common::Error PrinceEngine::run() { {
font1.getCharWidth(103);
}
+ delete font1stream;
Common::SeekableReadStream *room = SearchMan.createReadStreamForMember("room");
- _frontScreen = new Graphics::Surface();
- _frontScreen->create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
+ //_frontScreen = new Graphics::Surface();
+ //_frontScreen->create(640, 480, Graphics::PixelFormat::createFormatCLUT8());
if (room)
{
Graphics::BitmapDecoder roomBmp;
roomBmp.loadStream(*room);
- _roomBackground = roomBmp.getSurface();
+ //_roomBackground = roomBmp.getSurface();
_system->getPaletteManager()->setPalette(roomBmp.getPalette(), 0, 256);
- font1.drawString(_frontScreen, "Hello World", 10, 10, 640, 1);
+ //font1.drawString(_frontScreen, "Hello World", 10, 10, 640, 1);
MhwanhDecoder walizkaBmp;
if (walizka)
@@ -102,23 +105,23 @@ Common::Error PrinceEngine::run() { debug("Loading walizka");
if (walizkaBmp.loadStream(*walizka))
{
- _roomBackground = walizkaBmp.getSurface();
- _system->getPaletteManager()->setPalette(walizkaBmp.getPalette(), 0, 256);
+ _graph->_roomBackground = walizkaBmp.getSurface();
+ _graph->setPalette(walizkaBmp.getPalette());
}
}
+ _graph->change();
+
mainLoop();
}
delete room;
-
-
return Common::kNoError;
}
void PrinceEngine::mainLoop() {
- uint32 nextFrameTime = 0;
+ //uint32 nextFrameTime = 0;
while (!shouldQuit()) {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
@@ -137,24 +140,20 @@ void PrinceEngine::mainLoop() { case Common::EVENT_RBUTTONUP:
break;
case Common::EVENT_QUIT:
- _system->quit();
break;
default:
break;
}
}
- _system->copyRectToScreen((byte*)_roomBackground->getBasePtr(0,0), 640, 0, 0, 640, 480);
- _system->updateScreen();
+ if (shouldQuit())
+ return;
+
+ _graph->update();
_system->delayMillis(40);
}
}
-void PrinceEngine::setFullPalette() {
- _system->getPaletteManager()->setPalette(_palette, 0, 256);
-}
-
-
} // End of namespace Prince
diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 3ae6c6a221..0c79d36ca4 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -33,8 +33,6 @@ #include "engines/engine.h"
#include "engines/util.h"
-#include "graphics/surface.h"
-
#include "audio/mixer.h"
namespace Prince {
@@ -42,6 +40,7 @@ namespace Prince { struct PrinceGameDescription;
class PrinceEngine;
+class GraphicsMan;
class PrinceEngine : public Engine {
protected:
@@ -62,17 +61,9 @@ public: private:
Common::RandomSource *_rnd;
-
- byte _palette[768];
- Graphics::Surface *_frontScreen;
- const Graphics::Surface *_roomBackground;
-
- void mainLoop();
-
- void loadBackground(Common::SeekableReadStream *stream);
- void setFullPalette();
+ GraphicsMan *_graph;
- void drawSprite(Graphics::Surface *sprite, int32 x, int32 y, int32 mod);
+ void mainLoop();
};
|