aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
authorPaul Gilbert2014-03-05 07:27:39 -0500
committerPaul Gilbert2014-03-05 07:27:39 -0500
commit23ebeec600f8210601dd45fc42c21a596fa6d127 (patch)
treed5c28780ace8f5e74e393dc4dfa87bc0300a898a /engines/mads
parent568fc31b3090a70aa922479991540d4f5c2e918c (diff)
downloadscummvm-rg350-23ebeec600f8210601dd45fc42c21a596fa6d127.tar.gz
scummvm-rg350-23ebeec600f8210601dd45fc42c21a596fa6d127.tar.bz2
scummvm-rg350-23ebeec600f8210601dd45fc42c21a596fa6d127.zip
MADS: Further implementation of drawElements
Diffstat (limited to 'engines/mads')
-rw-r--r--engines/mads/animation.h1
-rw-r--r--engines/mads/graphics.cpp18
-rw-r--r--engines/mads/graphics.h28
-rw-r--r--engines/mads/interface.cpp87
-rw-r--r--engines/mads/interface.h60
-rw-r--r--engines/mads/mads.cpp2
-rw-r--r--engines/mads/mads.h3
-rw-r--r--engines/mads/module.mk1
-rw-r--r--engines/mads/msurface.cpp5
-rw-r--r--engines/mads/msurface.h5
-rw-r--r--engines/mads/scene.cpp23
-rw-r--r--engines/mads/scene.h1
-rw-r--r--engines/mads/scene_data.cpp52
-rw-r--r--engines/mads/scene_data.h21
-rw-r--r--engines/mads/sprites.cpp20
-rw-r--r--engines/mads/sprites.h7
16 files changed, 247 insertions, 87 deletions
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 297abf4eee..9498483fb6 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -29,6 +29,7 @@
#include "mads/msurface.h"
#include "mads/scene_data.h"
#include "mads/font.h"
+#include "mads/interface.h"
namespace MADS {
diff --git a/engines/mads/graphics.cpp b/engines/mads/graphics.cpp
index 267785b76b..f4d788fea5 100644
--- a/engines/mads/graphics.cpp
+++ b/engines/mads/graphics.cpp
@@ -26,5 +26,23 @@
namespace MADS {
+void ScreenSurface::init() {
+ setSize(g_system->getWidth(), g_system->getHeight());
+}
+
+void ScreenSurface::updateScreen() {
+ g_system->copyRectToScreen((const byte *)pixels, pitch, 0, 0, w, h);
+ g_system->updateScreen();
+}
+
+void ScreenSurface::transition(bool transitionFlag, bool surfaceFlag) {
+
+}
+
+void ScreenSurface::setPointer(MSurface *s) {
+ _pixels = s->getData();
+ _pitch = s->w;
+}
+
} // End of namespace MADS
diff --git a/engines/mads/graphics.h b/engines/mads/graphics.h
index cadbbc8e8e..b64bced245 100644
--- a/engines/mads/graphics.h
+++ b/engines/mads/graphics.h
@@ -24,12 +24,40 @@
#define MADS_GRAPHICS_H
#include "common/scummsys.h"
+#include "common/array.h"
+#include "mads/msurface.h"
namespace MADS {
#define MADS_SCREEN_WIDTH 320
#define MADS_SCREEN_HEIGHT 200
+class ScreenSurface : public MSurface {
+public:
+ Common::Point _offset;
+ byte *_pixels;
+ int _pitch;
+public:
+ /**
+ * Constructor
+ */
+ ScreenSurface() {}
+
+ /**
+ * Initialise the surface
+ */
+ void init();
+
+ void setPointer(MSurface *s);
+
+ /**
+ * Updates the screen with the contents of the surface
+ */
+ void updateScreen();
+
+ void transition(bool transitionFlag, bool surfaceFlag);
+};
+
} // End of namespace MADS
#endif /* MADS_GRAPHICS_H */
diff --git a/engines/mads/interface.cpp b/engines/mads/interface.cpp
new file mode 100644
index 0000000000..fa50cbd1be
--- /dev/null
+++ b/engines/mads/interface.cpp
@@ -0,0 +1,87 @@
+/* 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 "common/scummsys.h"
+#include "mads/mads.h"
+#include "mads/compression.h"
+#include "mads/interface.h"
+
+namespace MADS {
+
+void SceneNode::load(Common::SeekableReadStream *f) {
+ _walkPos.x = f->readSint16LE();
+ _walkPos.y = f->readSint16LE();
+ for (int i = 0; i < MAX_ROUTE_NODES; ++i)
+ _indexes[i] = f->readUint16LE();
+}
+
+/*------------------------------------------------------------------------*/
+
+InterfaceSurface::InterfaceSurface(MADSEngine *vm) : _vm(vm) {
+ _category = CAT_NONE;
+ _screenObjectsCount = 0;
+}
+
+
+void InterfaceSurface::load(const Common::String &resName) {
+ File f(resName);
+ MadsPack madsPack(&f);
+
+ // Load in the palette
+ Common::SeekableReadStream *palStream = madsPack.getItemStream(0);
+
+ RGB4 *gamePalP = &_vm->_palette->_gamePalette[0];
+ byte *palP = &_vm->_palette->_mainPalette[0];
+
+ for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) {
+ palP[0] = palStream->readByte();
+ palP[1] = palStream->readByte();
+ palP[2] = palStream->readByte();
+ gamePalP->r |= 1;
+ palStream->skip(3);
+ }
+ delete palStream;
+
+ // set the size for the interface
+ setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
+ Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1);
+ pixelsStream->read(getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
+ delete pixelsStream;
+}
+
+void InterfaceSurface::elementHighlighted() {
+ warning("TODO: InterfaceSurface::elementHighlighted");
+}
+
+void InterfaceSurface::writeText() {
+ warning("TODO: InterfaceSurface::writeText");
+}
+
+
+void InterfaceSurface::setBounds(const Common::Rect &r) {
+ _bounds = r;
+}
+
+/*------------------------------------------------------------------------*/
+
+
+} // End of namespace MADS
diff --git a/engines/mads/interface.h b/engines/mads/interface.h
new file mode 100644
index 0000000000..3295fa450e
--- /dev/null
+++ b/engines/mads/interface.h
@@ -0,0 +1,60 @@
+/* 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 MADS_INTERFACE_H
+#define MADS_INTERFACE_H
+
+#include "common/scummsys.h"
+#include "common/rect.h"
+#include "common/str.h"
+
+namespace MADS {
+
+class InterfaceSurface : public MSurface {
+private:
+ MADSEngine *_vm;
+public:
+ ScrCategory _category;
+ int _screenObjectsCount;
+ Common::Rect _bounds;
+ Common::Rect *_rectP;
+public:
+ /**
+ * Constructor
+ */
+ InterfaceSurface(MADSEngine *vm);
+
+ /**
+ * Loads an interface from a specified resource
+ */
+ void load(const Common::String &resName);
+
+ void elementHighlighted();
+
+ void writeText();
+
+ void setBounds(const Common::Rect &r);
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_INTERFACE_H */
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index fd2aebaecf..fcf03952c7 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -82,7 +82,7 @@ void MADSEngine::initialise() {
_events = new EventsManager(this);
_palette = new Palette(this);
_font = new Font(this);
- _screen.setSize(g_system->getWidth(), g_system->getHeight());
+ _screen.init();
_sound = new SoundManager(this, _mixer);
_userInterface = UserInterface::init(this);
_game = Game::init(this);
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 0d5e16ac47..abe6e790c2 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -35,6 +35,7 @@
#include "mads/events.h"
#include "mads/font.h"
#include "mads/game.h"
+#include "mads/graphics.h"
#include "mads/msurface.h"
#include "mads/resources.h"
#include "mads/sound.h"
@@ -97,7 +98,7 @@ public:
Game *_game;
Palette *_palette;
Resources *_resources;
- MSurface _screen;
+ ScreenSurface _screen;
SoundManager *_sound;
UserInterface *_userInterface;
bool _easyMouse;
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 2bff5b782e..6a44621283 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -18,6 +18,7 @@ MODULE_OBJS := \
game.o \
game_data.o \
graphics.o \
+ interface.o \
mads.o \
messages.o \
msurface.o \
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index bb9b3089df..5f7b37b1cd 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -199,11 +199,6 @@ void MSurface::empty() {
Common::fill(getBasePtr(0, 0), getBasePtr(0, h), _vm->_palette->BLACK);
}
-void MSurface::updateScreen() {
- g_system->copyRectToScreen((const byte *)pixels, pitch, 0, 0, w, h);
- g_system->updateScreen();
-}
-
void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds,
const Common::Point &destPos, int transparentColor) {
// Validation of the rectangle and position
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 7f4cec3c1c..7043cd4eff 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -132,11 +132,6 @@ public:
void empty();
/**
- * Updates the screen with the contents of the surface
- */
- void updateScreen();
-
- /**
* Copys a sub-section of another surface into the current one.
* @param src Source surface
* @param srcBounds Area of source surface to copy
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 994f58230e..1d489ddb2d 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -164,7 +164,6 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
_scaleRange = _sceneInfo->_maxScale - _sceneInfo->_minScale;
_spriteSlots.clear(false);
- _screenY = 0;
_interfaceY = MADS_SCENE_HEIGHT;
_spritesCount = _sprites.size();
@@ -432,6 +431,28 @@ void Scene::drawElements(bool transitionFlag, bool surfaceFlag) {
// Copy dirty areas to the main display surface
_dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _posAdjust);
+
+ // Set dirty areas
+ _spriteSlots.setDirtyAreas();
+ _textDisplay.setDirtyAreas();
+
+ //
+ _vm->_screen.setPointer(&_vm->_screen);
+ _interface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y,
+ _vm->_screen._offset.x + _vm->_screen.w, _vm->_screen._offset.y + _vm->_screen.h));
+
+ if (transitionFlag) {
+ // Fading in the screen
+ _vm->_screen.transition(transitionFlag, surfaceFlag);
+ _vm->_sound->startQueuedCommands();
+ } else {
+ // Copy dirty areas to the screen
+ _dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _vm->_screen._offset);
+ }
+
+ warning("TODO: sub_115A2");
+ _spriteSlots.cleanUp();
+ _textDisplay.cleanUp();
}
void Scene::leftClick() {
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index c466f97c02..d9bc15add1 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -112,7 +112,6 @@ public:
int _depthStyle;
int _bandsRange;
int _scaleRange;
- int _screenY;
int _interfaceY;
int _spritesCount;
int _v1A;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 371fa43501..00632f6d2e 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -471,30 +471,6 @@ void ARTHeader::load(Common::SeekableReadStream *f) {
/*------------------------------------------------------------------------*/
-void SceneNode::load(Common::SeekableReadStream *f) {
- _walkPos.x = f->readSint16LE();
- _walkPos.y = f->readSint16LE();
- for (int i = 0; i < MAX_ROUTE_NODES; ++i)
- _indexes[i] = f->readUint16LE();
-}
-
-/*------------------------------------------------------------------------*/
-
-InterfaceSurface::InterfaceSurface(MADSEngine *vm): _vm(vm) {
- _category = CAT_NONE;
- _screenObjectsCount = 0;
-}
-
-void InterfaceSurface::elementHighlighted() {
- warning("TODO: InterfaceSurface::elementHighlighted");
-}
-
-void InterfaceSurface::writeText() {
- warning("TODO: InterfaceSurface::writeText");
-}
-
-/*------------------------------------------------------------------------*/
-
void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
f->skip(3);
_spriteSetIndex = f->readByte();
@@ -507,34 +483,6 @@ void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
/*------------------------------------------------------------------------*/
-void InterfaceSurface::load(const Common::String &resName) {
- File f(resName);
- MadsPack madsPack(&f);
-
- // Load in the palette
- Common::SeekableReadStream *palStream = madsPack.getItemStream(0);
-
- RGB4 *gamePalP = &_vm->_palette->_gamePalette[0];
- byte *palP = &_vm->_palette->_mainPalette[0];
-
- for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) {
- palP[0] = palStream->readByte();
- palP[1] = palStream->readByte();
- palP[2] = palStream->readByte();
- gamePalP->r |= 1;
- palStream->skip(3);
- }
- delete palStream;
-
- // set the size for the interface
- setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
- Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1);
- pixelsStream->read(getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
- delete pixelsStream;
-}
-
-/*------------------------------------------------------------------------*/
-
SceneInfo *SceneInfo::init(MADSEngine *vm) {
if (vm->getGameID() == GType_RexNebular) {
return new SceneInfoNebular(vm);
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 15371e405f..ce785e76ae 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -277,27 +277,6 @@ public:
};
typedef Common::Array<SceneNode> SceneNodeList;
-class InterfaceSurface : public MSurface {
-private:
- MADSEngine *_vm;
-public:
- ScrCategory _category;
- int _screenObjectsCount;
-public:
- /**
- * Constructor
- */
- InterfaceSurface(MADSEngine *vm);
-
- /**
- * Loads an interface from a specified resource
- */
- void load(const Common::String &resName);
-
- void elementHighlighted();
-
- void writeText();
-};
/**
* Handles general data for a given scene
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 3cba6989b1..e7349f6c60 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -161,6 +161,19 @@ void SpriteSlots::deleteEntry(int index) {
remove_at(index);
}
+void SpriteSlots::setDirtyAreas() {
+ Scene &scene = _vm->_game->_scene;
+
+ for (uint i = 0; i < size(); ++i) {
+ if ((*this)[i]._spriteType >= ST_NONE) {
+ scene._dirtyAreas[i].setSpriteSlot(&(*this)[i]);
+
+ scene._dirtyAreas[i]._textActive = ((*this)[i]._spriteType <= ST_NONE) ? 0 : 1;
+ (*this)[i]._spriteType = ST_NONE;
+ }
+ }
+}
+
void SpriteSlots::fullRefresh(bool clearAll) {
if (clearAll)
Common::Array<SpriteSlot>::clear();
@@ -220,6 +233,13 @@ void SpriteSlots::drawBackground() {
}
}
+void SpriteSlots::cleanUp() {
+ for (int i = (int)size() - 1; i >= 0; --i) {
+ if ((*this)[i]._spriteType >= ST_NONE)
+ remove_at(i);
+ }
+}
+
/*------------------------------------------------------------------------*/
int SpriteSets::add(SpriteAsset *asset, int idx) {
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 6b131105dc..b1208d0df5 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -163,6 +163,11 @@ public:
void deleteEntry(int index);
/**
+ * Setup dirty areas for the sprite slots
+ */
+ void setDirtyAreas();
+
+ /**
* Adds a full screen refresh to the sprite slots
*/
void fullRefresh(bool clearAll = false);
@@ -182,6 +187,8 @@ public:
* Draw any sprites into the background of the scene
*/
void drawBackground();
+
+ void cleanUp();
};
class SpriteSets : public Common::Array<SpriteAsset *> {