diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/illusions/actor.cpp | 6 | ||||
-rw-r--r-- | engines/illusions/actor.h | 9 | ||||
-rw-r--r-- | engines/illusions/backgroundresource.cpp | 3 | ||||
-rw-r--r-- | engines/illusions/illusions.cpp | 32 | ||||
-rw-r--r-- | engines/illusions/illusions.h | 9 | ||||
-rw-r--r-- | engines/illusions/module.mk | 1 | ||||
-rw-r--r-- | engines/illusions/screen.cpp | 98 | ||||
-rw-r--r-- | engines/illusions/screen.h | 59 | ||||
-rw-r--r-- | engines/illusions/spritedrawqueue.cpp | 44 | ||||
-rw-r--r-- | engines/illusions/spritedrawqueue.h | 13 |
10 files changed, 203 insertions, 71 deletions
diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp index ee4f677187..d7d7fb5702 100644 --- a/engines/illusions/actor.cpp +++ b/engines/illusions/actor.cpp @@ -24,6 +24,7 @@ #include "illusions/actor.h" #include "illusions/camera.h" #include "illusions/input.h" +#include "illusions/screen.h" namespace Illusions { @@ -60,7 +61,7 @@ void Actor::unpause() { } void Actor::createSurface(SurfInfo &surfInfo) { - _surface = _vm->allocSurface(surfInfo); + _surface = _vm->_screen->allocSurface(surfInfo); if (_frameIndex) { if (_surfaceTextFlag) { /* TODO @@ -348,4 +349,7 @@ void Control::setActorFrameIndex(int16 frameIndex) { } } +// Controls + + } // End of namespace Illusions diff --git a/engines/illusions/actor.h b/engines/illusions/actor.h index 3dc87e2296..6216b31aa6 100644 --- a/engines/illusions/actor.h +++ b/engines/illusions/actor.h @@ -26,6 +26,7 @@ #include "illusions/actorresource.h" #include "illusions/graphics.h" #include "common/algorithm.h" +#include "common/list.h" #include "graphics/surface.h" namespace Illusions { @@ -142,6 +143,14 @@ public: // TODO 0000001C - 00000054 unknown }; +class Controls { +public: +public: + typedef Common::List<Control*> Items; + typedef Items::iterator ItemsIterator; + Items _controls; +}; + } // End of namespace Illusions #endif // ILLUSIONS_ACTOR_H diff --git a/engines/illusions/backgroundresource.cpp b/engines/illusions/backgroundresource.cpp index aef2a4ca9e..66f987a934 100644 --- a/engines/illusions/backgroundresource.cpp +++ b/engines/illusions/backgroundresource.cpp @@ -23,6 +23,7 @@ #include "illusions/illusions.h" #include "illusions/backgroundresource.h" #include "illusions/camera.h" +#include "illusions/screen.h" #include "common/str.h" namespace Illusions { @@ -192,7 +193,7 @@ void BackgroundItem::initSurface() { for (uint i = 0; i < _bgRes->_bgInfosCount; ++i) { BgInfo *bgInfo = &_bgRes->_bgInfos[i]; _panPoints[i] = bgInfo->_panPoint; - _surfaces[i] = _vm->allocSurface(bgInfo->_surfInfo); + _surfaces[i] = _vm->_screen->allocSurface(bgInfo->_surfInfo); drawTiles(_surfaces[i], bgInfo->_tileMap, bgInfo->_tilePixels); } } diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp index 3e1758ddc2..5a0c2ea710 100644 --- a/engines/illusions/illusions.cpp +++ b/engines/illusions/illusions.cpp @@ -27,11 +27,10 @@ #include "illusions/graphics.h" #include "illusions/input.h" #include "illusions/updatefunctions.h" -#include "illusions/spritedrawqueue.h" -#include "illusions/spritedecompressqueue.h" #include "illusions/actor.h" #include "illusions/actorresource.h" #include "illusions/thread.h" +#include "illusions/screen.h" #include "illusions/scriptresource.h" #include "illusions/scriptman.h" #include "illusions/time.h" @@ -87,6 +86,7 @@ Common::Error IllusionsEngine::run() { _resSys->addResourceLoader(0x00100000, new ActorResourceLoader(this)); _resSys->addResourceLoader(0x00110000, new BackgroundResourceLoader(this)); + _screen = new Screen(this); _input = new Input(); _scriptMan = new ScriptMan(this); _actorItems = new ActorItems(this); @@ -137,6 +137,7 @@ Common::Error IllusionsEngine::run() { delete _actorItems; delete _scriptMan; delete _input; + delete _screen; delete _resSys; return Common::kNoError; @@ -180,33 +181,6 @@ void IllusionsEngine::updateEvents() { } } -Graphics::Surface *IllusionsEngine::allocSurface(int16 width, int16 height) { - // TODO Use screen pixel format? - Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0); - Graphics::Surface *surface = new Graphics::Surface(); - surface->create(width, height, pixelFormat16); - return surface; -} - -Graphics::Surface *IllusionsEngine::allocSurface(SurfInfo &surfInfo) { - return allocSurface(surfInfo._dimensions._width, surfInfo._dimensions._height); -} - -bool IllusionsEngine::isDisplayOn() { - // TODO Move this outside into a screen class - return true; -} - -uint16 IllusionsEngine::getColorKey2() { - // TODO Move this outside into a screen class - return 0; -} - -Graphics::Surface *IllusionsEngine::getBackSurface() { - // TODO Move this outside into a screen class - return 0; -} - Common::Point *IllusionsEngine::getObjectActorPositionPtr(uint32 objectId) { // TODO Dummy, to be replaced later return 0; diff --git a/engines/illusions/illusions.h b/engines/illusions/illusions.h index 4b5a1683d5..efae32154f 100644 --- a/engines/illusions/illusions.h +++ b/engines/illusions/illusions.h @@ -57,6 +57,7 @@ class BackgroundResource; class Camera; class Control; class Input; +class Screen; class ScriptResource; class ScriptMan; @@ -78,19 +79,13 @@ public: void updateEvents(); + Screen *_screen; Input *_input; ScriptMan *_scriptMan; ActorItems *_actorItems; BackgroundItems *_backgroundItems; Camera *_camera; - // Screen functions - Graphics::Surface *allocSurface(int16 width, int16 height); - Graphics::Surface *allocSurface(SurfInfo &surfInfo); - bool isDisplayOn(); - uint16 getColorKey2(); - Graphics::Surface *getBackSurface(); - Common::Point *getObjectActorPositionPtr(uint32 objectId); Control *findControl(uint32 objectId); ActorType *findActorType(uint32 actorTypeId); diff --git a/engines/illusions/module.mk b/engines/illusions/module.mk index 8dd462c86e..e40a676d18 100644 --- a/engines/illusions/module.mk +++ b/engines/illusions/module.mk @@ -11,6 +11,7 @@ MODULE_OBJS := \ illusions.o \ input.o \ resourcesystem.o \ + screen.o \ scriptman.o \ scriptopcodes.o \ scriptresource.o \ diff --git a/engines/illusions/screen.cpp b/engines/illusions/screen.cpp new file mode 100644 index 0000000000..1b33b0c856 --- /dev/null +++ b/engines/illusions/screen.cpp @@ -0,0 +1,98 @@ +/* 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 "illusions/illusions.h" +#include "illusions/screen.h" +#include "illusions/graphics.h" +#include "illusions/spritedrawqueue.h" +#include "illusions/spritedecompressqueue.h" + +namespace Illusions { + +// Screen + +Screen::Screen(IllusionsEngine *vm) + : _vm(vm) { + _displayOn = true; + _backSurface = allocSurface(640, 480); + _decompressQueue = new SpriteDecompressQueue(); + _drawQueue = new SpriteDrawQueue(this); +} + +Screen::~Screen() { + delete _drawQueue; + delete _decompressQueue; + _backSurface->free(); + delete _backSurface; +} + +Graphics::Surface *Screen::allocSurface(int16 width, int16 height) { + // TODO Use screen pixel format? + Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0); + Graphics::Surface *surface = new Graphics::Surface(); + surface->create(width, height, pixelFormat16); + return surface; +} + +Graphics::Surface *Screen::allocSurface(SurfInfo &surfInfo) { + return allocSurface(surfInfo._dimensions._width, surfInfo._dimensions._height); +} + +bool Screen::isDisplayOn() { + return _displayOn; +} + +uint16 Screen::getColorKey2() { + return _colorKey2; +} + +Graphics::Surface *Screen::getBackSurface() { + // TODO Move this outside into a screen class + return 0; +} + +void Screen::updateSprites() { + _decompressQueue->decompressAll(); + // NOTE Skipped doShiftBrightness and related as it seems to be unused + _drawQueue->drawAll(); + if (!_displayOn) // TODO Check if a video is playing then don't do it + _backSurface->fillRect(Common::Rect(_backSurface->w, _backSurface->h), 0); + g_system->copyRectToScreen((byte*)_backSurface->getBasePtr(0, 0), _backSurface->pitch, 0, 0, _backSurface->w, _backSurface->h); +} + +void Screen::drawSurface10(int16 destX, int16 destY, Graphics::Surface *surface, Common::Rect &srcRect, uint16 colorKey) { + // TODO +} + +void Screen::drawSurface11(int16 destX, int16 destY, Graphics::Surface *surface, Common::Rect &srcRect) { + // TODO +} + +void Screen::drawSurface20(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect, uint16 colorKey) { + // TODO +} + +void Screen::drawSurface21(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect) { + // TODO +} + +} // End of namespace Illusions diff --git a/engines/illusions/screen.h b/engines/illusions/screen.h new file mode 100644 index 0000000000..5d5ead2476 --- /dev/null +++ b/engines/illusions/screen.h @@ -0,0 +1,59 @@ +/* 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 ILLUSIONS_SCREEN_H +#define ILLUSIONS_SCREEN_H + +#include "illusions/spritedrawqueue.h" +#include "illusions/spritedecompressqueue.h" +#include "graphics/surface.h" + +namespace Illusions { + +class IllusionsEngine; + +class Screen { +public: + Screen(IllusionsEngine *vm); + ~Screen(); + Graphics::Surface *allocSurface(int16 width, int16 height); + Graphics::Surface *allocSurface(SurfInfo &surfInfo); + bool isDisplayOn(); + uint16 getColorKey2(); + Graphics::Surface *getBackSurface(); + void updateSprites(); + void drawSurface10(int16 destX, int16 destY, Graphics::Surface *surface, Common::Rect &srcRect, uint16 colorKey); + void drawSurface11(int16 destX, int16 destY, Graphics::Surface *surface, Common::Rect &srcRect); + void drawSurface20(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect, uint16 colorKey); + void drawSurface21(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect); +public: + IllusionsEngine *_vm; + bool _displayOn; + uint16 _colorKey2; + SpriteDecompressQueue *_decompressQueue; + SpriteDrawQueue *_drawQueue; + Graphics::Surface *_backSurface; +}; + +} // End of namespace Illusions + +#endif // ILLUSIONS_SCREEN_H diff --git a/engines/illusions/spritedrawqueue.cpp b/engines/illusions/spritedrawqueue.cpp index a21ca15083..2cffb0c28b 100644 --- a/engines/illusions/spritedrawqueue.cpp +++ b/engines/illusions/spritedrawqueue.cpp @@ -21,11 +21,12 @@ */ #include "illusions/spritedrawqueue.h" +#include "illusions/screen.h" namespace Illusions { -SpriteDrawQueue::SpriteDrawQueue(IllusionsEngine *vm) - : _vm(vm) { +SpriteDrawQueue::SpriteDrawQueue(Screen *screen) + : _screen(screen) { } SpriteDrawQueue::~SpriteDrawQueue() { @@ -39,7 +40,7 @@ bool SpriteDrawQueue::draw(SpriteDrawQueueItem *item) { return false; } - if (!_vm->isDisplayOn()) { + if (!_screen->isDisplayOn()) { if (item->_drawFlags) *item->_drawFlags &= ~4; return true; @@ -51,18 +52,16 @@ bool SpriteDrawQueue::draw(SpriteDrawQueueItem *item) { if (!calcItemRect(item, srcRect, dstRect)) return true; - _backSurface = _vm->getBackSurface(); - if (item->_scale == 100) { if (item->_flags & 1) - drawSurface10(dstRect.left, dstRect.top, item->_surface, srcRect, _vm->getColorKey2()); + _screen->drawSurface10(dstRect.left, dstRect.top, item->_surface, srcRect, _screen->getColorKey2()); else - drawSurface11(dstRect.left, dstRect.top, item->_surface, srcRect); + _screen->drawSurface11(dstRect.left, dstRect.top, item->_surface, srcRect); } else { if (item->_flags & 1) - drawSurface20(dstRect, item->_surface, srcRect, _vm->getColorKey2()); + _screen->drawSurface20(dstRect, item->_surface, srcRect, _screen->getColorKey2()); else - drawSurface21(dstRect, item->_surface, srcRect); + _screen->drawSurface21(dstRect, item->_surface, srcRect); } if (item->_drawFlags) @@ -71,6 +70,17 @@ bool SpriteDrawQueue::draw(SpriteDrawQueueItem *item) { return true; } +void SpriteDrawQueue::drawAll() { + SpriteDrawQueueListIterator it = _queue.begin(); + while (it != _queue.end()) { + if (draw(*it)) { + delete *it; + it = _queue.erase(it); + } else + ++it; + } +} + void SpriteDrawQueue::insertSprite(byte *drawFlags, Graphics::Surface *surface, WidthHeight &dimensions, Common::Point &drawPosition, Common::Point &controlPosition, int priority, int16 scale, uint16 flags) { SpriteDrawQueueItem *item = new SpriteDrawQueueItem(); @@ -177,20 +187,4 @@ bool SpriteDrawQueue::calcItemRect(SpriteDrawQueueItem *item, Common::Rect &srcR return true; } -void SpriteDrawQueue::drawSurface10(int16 destX, int16 destY, Graphics::Surface *surface, Common::Rect &srcRect, uint16 colorKey) { - // TODO -} - -void SpriteDrawQueue::drawSurface11(int16 destX, int16 destY, Graphics::Surface *surface, Common::Rect &srcRect) { - // TODO -} - -void SpriteDrawQueue::drawSurface20(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect, uint16 colorKey) { - // TODO -} - -void SpriteDrawQueue::drawSurface21(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect) { - // TODO -} - } // End of namespace Illusions diff --git a/engines/illusions/spritedrawqueue.h b/engines/illusions/spritedrawqueue.h index 83dd35206c..30b999a15a 100644 --- a/engines/illusions/spritedrawqueue.h +++ b/engines/illusions/spritedrawqueue.h @@ -31,6 +31,8 @@ namespace Illusions { +class Screen; + struct SpriteDrawQueueItem { byte *_drawFlags; int16 _kind; @@ -46,9 +48,10 @@ struct SpriteDrawQueueItem { class SpriteDrawQueue { public: - SpriteDrawQueue(IllusionsEngine *vm); + SpriteDrawQueue(Screen *screen); ~SpriteDrawQueue(); bool draw(SpriteDrawQueueItem *item); + void drawAll(); void insertSprite(byte *drawFlags, Graphics::Surface *surface, WidthHeight &dimensions, Common::Point &drawPosition, Common::Point &controlPosition, int priority, int16 scale, uint16 flags); void insertSurface(Graphics::Surface *surface, WidthHeight &dimensions, @@ -67,16 +70,10 @@ protected: } }; - IllusionsEngine *_vm; - Graphics::Surface *_backSurface; + Screen *_screen; SpriteDrawQueueList _queue; void insert(SpriteDrawQueueItem *item, int priority); bool calcItemRect(SpriteDrawQueueItem *item, Common::Rect &srcRect, Common::Rect &dstRect); - // TODO Possibly move these into a Screen class - void drawSurface10(int16 destX, int16 destY, Graphics::Surface *surface, Common::Rect &srcRect, uint16 colorKey); - void drawSurface11(int16 destX, int16 destY, Graphics::Surface *surface, Common::Rect &srcRect); - void drawSurface20(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect, uint16 colorKey); - void drawSurface21(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect); }; } // End of namespace Illusions |