aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/neverhood/background.cpp89
-rw-r--r--engines/neverhood/background.h56
-rw-r--r--engines/neverhood/graphics.cpp2
-rw-r--r--engines/neverhood/module.h1
-rw-r--r--engines/neverhood/module.mk1
-rw-r--r--engines/neverhood/module1500.cpp4
-rw-r--r--engines/neverhood/neverhood.cpp2
-rw-r--r--engines/neverhood/resource.cpp3
-rw-r--r--engines/neverhood/resource.h2
-rw-r--r--engines/neverhood/scene.cpp25
-rw-r--r--engines/neverhood/scene.h9
11 files changed, 179 insertions, 15 deletions
diff --git a/engines/neverhood/background.cpp b/engines/neverhood/background.cpp
new file mode 100644
index 0000000000..abfa50733d
--- /dev/null
+++ b/engines/neverhood/background.cpp
@@ -0,0 +1,89 @@
+/* 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 "neverhood/background.h"
+
+namespace Neverhood {
+
+// Background
+
+Background::Background(NeverhoodEngine *vm, int objectPriority)
+ : Entity(vm, objectPriority), _surface(NULL), _spriteResource(vm) {
+ // Empty
+}
+
+Background::Background(NeverhoodEngine *vm, uint32 fileHash, int objectPriority, int surfacePriority)
+ : Entity(vm, objectPriority), _surface(NULL), _spriteResource(vm) {
+
+ _spriteResource.load(fileHash);
+ createSurface(surfacePriority, _spriteResource.getDimensions().width, _spriteResource.getDimensions().height);
+ _surface->drawSpriteResource(_spriteResource);
+
+}
+
+Background::~Background() {
+ delete _surface;
+}
+
+void Background::createSurface(int surfacePriority, int16 width, int16 height) {
+ _surface = new BaseSurface(_vm, surfacePriority, width, height);
+ _spriteResource.getPosition().x = width;
+ _spriteResource.getPosition().y = height;
+}
+
+void Background::load(uint32 fileHash) {
+ _spriteResource.load(fileHash);
+ if (_surface)
+ _surface->drawSpriteResource(_spriteResource);
+}
+
+// DirtyBackground
+
+DirtyBackground::DirtyBackground(NeverhoodEngine *vm, const char *fileName, int objectPriority, int surfacePriority)
+ : Background(vm, objectPriority) {
+
+ // TODO _spriteResource.load(calcHash(fileName));
+ createSurface(surfacePriority, _spriteResource.getDimensions().width, _spriteResource.getDimensions().height);
+ _surface->drawSpriteResource(_spriteResource);
+
+}
+
+DirtyBackground::DirtyBackground(NeverhoodEngine *vm, uint32 fileHash, int objectPriority, int surfacePriority)
+ : Background(vm, objectPriority) {
+
+ _spriteResource.load(fileHash);
+ createSurface(surfacePriority, _spriteResource.getDimensions().width, _spriteResource.getDimensions().height);
+ _surface->drawSpriteResource(_spriteResource);
+
+}
+
+void DirtyBackground::createSurface(int surfacePriority, int16 width, int16 height) {
+
+ // TODO: Later use a DirtySurface once it is implemented
+ _surface = new BaseSurface(_vm, surfacePriority, width, height);
+ _spriteResource.getPosition().x = width;
+ _spriteResource.getPosition().y = height;
+
+}
+
+
+} // End of namespace Neverhood
diff --git a/engines/neverhood/background.h b/engines/neverhood/background.h
new file mode 100644
index 0000000000..733f80b83d
--- /dev/null
+++ b/engines/neverhood/background.h
@@ -0,0 +1,56 @@
+/* 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_BACKGROUND_H
+#define NEVERHOOD_BACKGROUND_H
+
+#include "neverhood/neverhood.h"
+#include "neverhood/entity.h"
+#include "neverhood/graphics.h"
+#include "neverhood/resource.h"
+
+namespace Neverhood {
+
+class Background : public Entity {
+public:
+ Background(NeverhoodEngine *vm, int objectPriority);
+ Background(NeverhoodEngine *vm, uint32 fileHash, int objectPriority, int surfacePriority);
+ virtual ~Background();
+ BaseSurface *getSurface() { return _surface; }
+ void createSurface(int surfacePriority, int16 width, int16 height);
+ void load(uint32 fileHash);
+protected:
+ BaseSurface *_surface;
+ SpriteResource _spriteResource;
+};
+
+class DirtyBackground : public Background {
+public:
+ DirtyBackground(NeverhoodEngine *vm, const char *fileName, int objectPriority, int surfacePriority);
+ DirtyBackground(NeverhoodEngine *vm, uint32 fileHash, int objectPriority, int surfacePriority);
+ void createSurface(int surfacePriority, int16 width, int16 height);
+
+};
+
+} // End of namespace Neverhood
+
+#endif /* NEVERHOOD_BACKGROUND_H */
diff --git a/engines/neverhood/graphics.cpp b/engines/neverhood/graphics.cpp
index d7c1064948..2a86966cf5 100644
--- a/engines/neverhood/graphics.cpp
+++ b/engines/neverhood/graphics.cpp
@@ -32,6 +32,7 @@ BaseSurface::BaseSurface(NeverhoodEngine *vm, int priority, int16 width, int16 h
_drawRect.y = 0;
_drawRect.width = width;
_drawRect.height = height;
+ // TODO: Check if _sysRect is needed at all in the reimplementation...
_sysRect.x = 0;
_sysRect.y = 0;
_sysRect.width = (width + 3) & 0xFFFC; // align by 4 bytes
@@ -49,6 +50,7 @@ BaseSurface::~BaseSurface() {
}
void BaseSurface::draw() {
+ debug("BaseSurface::draw()");
// TODO
}
diff --git a/engines/neverhood/module.h b/engines/neverhood/module.h
index b59b532fad..d3c7b69169 100644
--- a/engines/neverhood/module.h
+++ b/engines/neverhood/module.h
@@ -26,6 +26,7 @@
#define NEVERHOOD_MODULE_H
#include "neverhood/neverhood.h"
+#include "neverhood/background.h"
#include "neverhood/entity.h"
#include "neverhood/graphics.h"
#include "neverhood/palette.h"
diff --git a/engines/neverhood/module.mk b/engines/neverhood/module.mk
index e51565f76b..cc7f9e1d0d 100644
--- a/engines/neverhood/module.mk
+++ b/engines/neverhood/module.mk
@@ -1,6 +1,7 @@
MODULE := engines/neverhood
MODULE_OBJS = \
+ background.o \
blbarchive.o \
detection.o \
entity.o \
diff --git a/engines/neverhood/module1500.cpp b/engines/neverhood/module1500.cpp
index 97d125a45f..8c4cb9c021 100644
--- a/engines/neverhood/module1500.cpp
+++ b/engines/neverhood/module1500.cpp
@@ -116,12 +116,12 @@ Scene1501::Scene1501(NeverhoodEngine *vm, Module *parentModule, uint32 backgroun
_surfaceFlag = true;
+ _background = addBackground(new DirtyBackground(_vm, backgroundFileHash, 0, 0));
+
_palette = new Palette(_vm);//DUMMY!
/* TODO
- _background = addBackground(new Class301(_vm, backgroundFileHash, 0, 0));
-
_palette = new Palette2(_vm);
_palette->usePalette();
addEntity(_palette);
diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp
index 4baff5eafa..207bd382cf 100644
--- a/engines/neverhood/neverhood.cpp
+++ b/engines/neverhood/neverhood.cpp
@@ -126,6 +126,7 @@ Common::Error NeverhoodEngine::run() {
_gameModule = new GameModule(this);
+ // Preliminary main loop, needs some more work but works for testing
while (1) {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
@@ -165,6 +166,7 @@ Common::Error NeverhoodEngine::run() {
}
_gameModule->handleUpdate();
+ _gameModule->draw();
_system->updateScreen();
}
diff --git a/engines/neverhood/resource.cpp b/engines/neverhood/resource.cpp
index 84eab7fe0e..300cf8195a 100644
--- a/engines/neverhood/resource.cpp
+++ b/engines/neverhood/resource.cpp
@@ -46,6 +46,7 @@ void SpriteResource::draw(byte *dest, int destPitch, bool flipX, bool flipY) {
}
bool SpriteResource::load(uint32 fileHash) {
+ debug("SpriteResource::load(%08X)", fileHash);
// TODO: Later merge with load2 and make the mode a parameter
unload();
_resourceHandle = _vm->_res->useResource(fileHash);
@@ -100,6 +101,7 @@ PaletteResource::~PaletteResource() {
}
bool PaletteResource::load(uint32 fileHash) {
+ debug("PaletteResource::load(%08X)", fileHash);
unload();
_resourceHandle = _vm->_res->useResource(fileHash);
if (_resourceHandle != -1) {
@@ -152,6 +154,7 @@ AnimResource::~AnimResource() {
}
bool AnimResource::load(uint32 fileHash) {
+ debug("AnimResource::load(%08X)", fileHash);
if (fileHash == _fileHash)
return true;
diff --git a/engines/neverhood/resource.h b/engines/neverhood/resource.h
index 6a76a73a64..868bafdc44 100644
--- a/engines/neverhood/resource.h
+++ b/engines/neverhood/resource.h
@@ -37,7 +37,7 @@ public:
bool load2(uint32 fileHash);
void unload();
const NDimensions& getDimensions() { return _dimensions; }
- const NPoint& getPosition() { return _position; }
+ NPoint& getPosition() { return _position; }
protected:
NeverhoodEngine *_vm;
int _resourceHandle;
diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp
index f1209318ec..6c3aae1e29 100644
--- a/engines/neverhood/scene.cpp
+++ b/engines/neverhood/scene.cpp
@@ -39,7 +39,7 @@ Scene::Scene(NeverhoodEngine *vm, Module *parentModule, bool clearHitRects)
// TODO _playerSprite = NULL;
// TODO _mouseSprite = NULL;
_palette = NULL;
- // TODO _background = NULL;
+ _background = NULL;
// TODO _field_8E = -1;
if (clearHitRects) {
// TODO g_Class700->setHitRects(NULL, 0);
@@ -53,7 +53,7 @@ Scene::Scene(NeverhoodEngine *vm, Module *parentModule, bool clearHitRects)
_messageListFlag = true;
_surfaceFlag = false;
_messageList2 = NULL;
- // TODO _smackerPlayer = NULL;
+ _smackerPlayer = NULL;
_smkFileHash = 0;
_messageListFlag2 = false;
_messageValue = -1;
@@ -78,26 +78,25 @@ Scene::~Scene() {
}
void Scene::draw() {
+ debug("Scene::draw()");
//**ALL TODO
-#if 0
if (_smackerPlayer) {
if (_surfaceFlag) {
- g_screen->resetDirtyRects();
- g_screen->copyDirtyRects();
- g_screen->addDirtyRects();
+ // TODO g_screen->resetDirtyRects();
+ // TODO g_screen->copyDirtyRects();
+ // TODO g_screen->addDirtyRects();
}
- _smackerPlayer->_surface->draw();
+ // TODO _smackerPlayer->_surface->draw();
} else {
if (_surfaceFlag) {
- g_screen->copyDirtyRects();
+ // TODO g_screen->copyDirtyRects();
for (Common::Array<BaseSurface*>::iterator iter = _surfaces.begin(); iter != _surfaces.end(); iter++)
(*iter)->addDirtyRect();
- g_screen->addDirtyRects();
+ // TODO g_screen->addDirtyRects();
}
for (Common::Array<BaseSurface*>::iterator iter = _surfaces.begin(); iter != _surfaces.end(); iter++)
(*iter)->draw();
}
-#endif
}
void Scene::addEntity(Entity *entity) {
@@ -170,6 +169,12 @@ void Scene::deleteSprite(Sprite **sprite) {
*sprite = NULL;
}
+Background *Scene::addBackground(Background *background) {
+ addEntity(background);
+ addSurface(background->getSurface());
+ return background;
+}
+
void Scene::update() {
if (_smkFileHash != 0) {
diff --git a/engines/neverhood/scene.h b/engines/neverhood/scene.h
index e5a3d0ecee..c64c2bfbef 100644
--- a/engines/neverhood/scene.h
+++ b/engines/neverhood/scene.h
@@ -25,6 +25,7 @@
#include "common/array.h"
#include "neverhood/neverhood.h"
+#include "neverhood/background.h"
#include "neverhood/entity.h"
#include "neverhood/graphics.h"
#include "neverhood/module.h"
@@ -38,6 +39,9 @@ struct MessageListItem {
uint32 messageValue;
};
+class SmackerPlayer { // DUMMY!
+};
+
class Scene : public Entity {
public:
Scene(NeverhoodEngine *vm, Module *parentModule, bool clearHitRects);
@@ -50,6 +54,7 @@ public:
Sprite *addSprite(Sprite *sprite);
void setSurfacePriority(BaseSurface *surface, int priority);
void deleteSprite(Sprite **sprite);
+ Background *addBackground(Background *background);
protected:
Module *_parentModule;
Common::Array<Entity*> _entities;
@@ -71,12 +76,12 @@ protected:
// TODO 00000090 playerSprite dd ?
// TODO 00000094 mouseSprite dd ?
Palette *_palette;
- // TODO Background *_background;
+ Background *_background;
bool _surfaceFlag;
bool _messageListFlag;
MessageListItem *_messageList2;
int _messageListStatus;
- // TODO 000000B0 smackerPlayer dd ?
+ SmackerPlayer *_smackerPlayer;
void (Entity::*_savedUpdateHandlerCb)();
uint32 (Entity::*_savedMessageHandlerCb)(int messageNum, const MessageParam &param, Entity *sender);
bool _smackerDone;