aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-12-26 13:10:30 +1100
committerPaul Gilbert2014-12-26 13:10:30 +1100
commit1249bc03fdbf6d1bc390f9aea45b482cbb258e33 (patch)
tree50818636b4b4f3722355afb997c1aab6262539a1 /engines
parent42afa00392372b68013a871e90857dc151ae7c2f (diff)
downloadscummvm-rg350-1249bc03fdbf6d1bc390f9aea45b482cbb258e33.tar.gz
scummvm-rg350-1249bc03fdbf6d1bc390f9aea45b482cbb258e33.tar.bz2
scummvm-rg350-1249bc03fdbf6d1bc390f9aea45b482cbb258e33.zip
XEEN: Implemented horizontal and vertical page merging
Diffstat (limited to 'engines')
-rw-r--r--engines/xeen/darkside/darkside_game.cpp19
-rw-r--r--engines/xeen/resources.cpp6
-rw-r--r--engines/xeen/screen.cpp83
-rw-r--r--engines/xeen/screen.h23
-rw-r--r--engines/xeen/xsurface.h2
5 files changed, 130 insertions, 3 deletions
diff --git a/engines/xeen/darkside/darkside_game.cpp b/engines/xeen/darkside/darkside_game.cpp
index bc0d156f7f..2e9186e42f 100644
--- a/engines/xeen/darkside/darkside_game.cpp
+++ b/engines/xeen/darkside/darkside_game.cpp
@@ -21,6 +21,8 @@
*/
#include "xeen/darkside/darkside_game.h"
+#include "xeen/resources.h"
+#include "xeen/screen.h"
namespace Xeen {
@@ -33,6 +35,23 @@ void DarkSideEngine::playGame() {
}
void DarkSideEngine::darkSideIntro() {
+ //sub_28F40
+ _screen->loadPalette("dark.pal");
+ File special("special.bin");
+ SpriteResource nwc[4] = {
+ SpriteResource("nwc1.int"), SpriteResource("nwc2.int"),
+ SpriteResource("nwc3.int"), SpriteResource("nwc4.int")
+ };
+ File voc[3] = {
+ File("dragon1.voc"), File("dragon2.voc"), File("dragon3.voc")
+ };
+
+ _screen->loadBackground("nwc1.raw");
+ _screen->loadPage(0);
+ _screen->loadBackground("nwc2.raw");
+ _screen->loadPage(1);
+
+ _screen->horizMerge(0);
}
} // End of namespace Xeen
diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp
index 3a1994da4e..b005d7431d 100644
--- a/engines/xeen/resources.cpp
+++ b/engines/xeen/resources.cpp
@@ -280,7 +280,7 @@ void SpriteResource::decodeFrame(File &f, uint16 offset, XSurface &s) {
// Get cell header
f.seek(offset);
int xOffset = f.readUint16LE();
- int width = f.readUint16LE();
+ f.skip(2);
int yOffset = f.readUint16LE();
int height = f.readUint16LE();
@@ -288,7 +288,7 @@ void SpriteResource::decodeFrame(File &f, uint16 offset, XSurface &s) {
const int patternSteps[] = { 0, 1, 1, 1, 2, 2, 3, 3, 0, -1, -1, -1, -2, -2, -3, -3 };
// Main loop
- int byteCount, opr1, opr2;
+ int opr1, opr2;
int32 pos;
for (int yPos = yOffset, byteCount = 0; yPos < height + yOffset; yPos++, byteCount = 0) {
// The number of bytes in this scan line
@@ -298,7 +298,7 @@ void SpriteResource::decodeFrame(File &f, uint16 offset, XSurface &s) {
// Skip the specified number of scan lines
yPos += f.readByte();
} else {
- // Skip the transparent color at the beginning of the scan line
+ // Skip the transparent pixels at the beginning of the scan line
int xPos = f.readByte() + xOffset; ++byteCount;
byte *destP = (byte *)s.getBasePtr(xPos, yPos);
diff --git a/engines/xeen/screen.cpp b/engines/xeen/screen.cpp
index 038222bfe2..4783890a60 100644
--- a/engines/xeen/screen.cpp
+++ b/engines/xeen/screen.cpp
@@ -21,6 +21,7 @@
*/
#include "xeen/screen.h"
+#include "xeen/resources.h"
namespace Xeen {
@@ -28,6 +29,7 @@ namespace Xeen {
* Constructor
*/
Screen::Screen(XeenEngine *vm) : _vm(vm) {
+
}
void Screen::update() {
@@ -100,4 +102,85 @@ bool Screen::unionRectangle(Common::Rect &destRect, const Common::Rect &src1, co
return !destRect.isEmpty();
}
+/**
+ * Load a palette resource into the temporary palette
+ */
+void Screen::loadPalette(const Common::String &name) {
+ File f(name);
+ f.read(_tempPaltte, PALETTE_SIZE);
+}
+
+/**
+ * Load a background resource into memory
+ */
+void Screen::loadBackground(const Common::String &name) {
+ File f(name);
+
+ _background.create(SCREEN_WIDTH, SCREEN_HEIGHT);
+ assert(f.size() == (SCREEN_WIDTH * SCREEN_HEIGHT));
+ f.read((byte *)_background.getPixels(), SCREEN_WIDTH * SCREEN_HEIGHT);
+}
+
+/**
+ * Copy a loaded background into a display page
+ */
+void Screen::loadPage(int pageNum) {
+ assert(pageNum == 0 || pageNum == 1);
+ if (_pages[0].empty()) {
+ _pages[0].create(SCREEN_WIDTH, SCREEN_HEIGHT);
+ _pages[1].create(SCREEN_WIDTH, SCREEN_HEIGHT);
+ }
+
+ _pages[pageNum].blitFrom(_background);
+}
+
+/**
+ * Merge the two pages along a horizontal split point
+ */
+void Screen::horizMerge(int xp) {
+ if (_pages[0].empty())
+ return;
+
+ for (int y = 0; y < SCREEN_HEIGHT; ++y) {
+ byte *destP = (byte *)_background.getBasePtr(0, y);
+ const byte *srcP = (const byte *)_pages[0].getBasePtr(0, y);
+ Common::copy(srcP, srcP + SCREEN_WIDTH - xp, destP);
+
+ if (xp != 0) {
+ srcP = (const byte *)_pages[1].getBasePtr(xp, y);
+ Common::copy(srcP, srcP + SCREEN_WIDTH - xp, destP + xp);
+ }
+ }
+}
+
+/**
+ * Merge the two pages along a vertical split point
+ */
+void Screen::vertMerge(int yp) {
+ if (_pages[0].empty())
+ return;
+
+ for (int y = 0; y < SCREEN_HEIGHT - yp; ++y) {
+ const byte *srcP = (const byte *)_pages[0].getBasePtr(0, y);
+ byte *destP = (byte *)_background.getBasePtr(0, y);
+ Common::copy(srcP, srcP + SCREEN_WIDTH, destP);
+ }
+
+ for (int y = yp; y < SCREEN_HEIGHT; ++y) {
+ const byte *srcP = (const byte *)_pages[1].getBasePtr(0, y);
+ byte *destP = (byte *)_background.getBasePtr(0, y);
+ Common::copy(srcP, srcP + SCREEN_WIDTH, destP);
+ }
+}
+
+void Screen::draw(void *data) {
+ // TODO: Figure out data structure that can be passed to method
+ assert(!data);
+ drawBackground();
+}
+
+void Screen::drawBackground() {
+
+}
+
} // End of namespace Xeen
diff --git a/engines/xeen/screen.h b/engines/xeen/screen.h
index 491b702ded..645c4da4c7 100644
--- a/engines/xeen/screen.h
+++ b/engines/xeen/screen.h
@@ -31,16 +31,27 @@
namespace Xeen {
+#define SCREEN_WIDTH 320
+#define SCREEN_HEIGHT 200
+#define PALETTE_COUNT 256
+#define PALETTE_SIZE (256 * 3)
+
class XeenEngine;
class Screen: public XSurface {
private:
XeenEngine *_vm;
Common::List<Common::Rect> _dirtyRects;
+ byte _mainPalette[PALETTE_SIZE];
+ byte _tempPaltte[PALETTE_SIZE];
+ XSurface _background;
+ XSurface _pages[2];
void mergeDirtyRects();
bool unionRectangle(Common::Rect &destRect, const Common::Rect &src1, const Common::Rect &src2);
+
+ void drawBackground();
public:
virtual void transBlitFrom(const XSurface &src, const Common::Point &destPos);
@@ -51,6 +62,18 @@ public:
void update();
void addDirtyRect(const Common::Rect &r);
+
+ void loadPalette(const Common::String &name);
+
+ void loadBackground(const Common::String &name);
+
+ void loadPage(int pageNum);
+
+ void horizMerge(int xp);
+
+ void vertMerge(int yp);
+
+ void draw(void *data);
};
} // End of namespace Xeen
diff --git a/engines/xeen/xsurface.h b/engines/xeen/xsurface.h
index 7a189fac1d..c2d6e78d8d 100644
--- a/engines/xeen/xsurface.h
+++ b/engines/xeen/xsurface.h
@@ -45,6 +45,8 @@ public:
void transBlitFrom(const XSurface &src);
void blitFrom(const XSurface &src);
+
+ bool empty() const { return getPixels() == nullptr; }
};
} // End of namespace Xeen