aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2013-07-16 23:54:18 +0300
committerEugene Sandulenko2013-09-06 14:48:18 +0300
commit57e03aedd3924cc9f675594b4b504b4f42958b40 (patch)
treefe3d1c73665cc2cf9159c50cf3f34a80f50e15b7
parent51a5b5c9c51ac40c3ec27e4b55f8c9118c9a580f (diff)
downloadscummvm-rg350-57e03aedd3924cc9f675594b4b504b4f42958b40.tar.gz
scummvm-rg350-57e03aedd3924cc9f675594b4b504b4f42958b40.tar.bz2
scummvm-rg350-57e03aedd3924cc9f675594b4b504b4f42958b40.zip
FULLPIPE: Initial code for bitmap rendering
-rw-r--r--engines/fullpipe/fullpipe.cpp6
-rw-r--r--engines/fullpipe/fullpipe.h2
-rw-r--r--engines/fullpipe/gfx.cpp272
-rw-r--r--engines/fullpipe/gfx.h23
-rw-r--r--engines/fullpipe/sound.cpp4
-rw-r--r--engines/fullpipe/stateloader.cpp2
-rw-r--r--engines/fullpipe/statics.cpp2
-rw-r--r--engines/fullpipe/utils.cpp17
-rw-r--r--engines/fullpipe/utils.h4
9 files changed, 297 insertions, 35 deletions
diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp
index c826d21ec5..f49edc75d1 100644
--- a/engines/fullpipe/fullpipe.cpp
+++ b/engines/fullpipe/fullpipe.cpp
@@ -64,8 +64,12 @@ FullpipeEngine::~FullpipeEngine() {
}
Common::Error FullpipeEngine::run() {
+
+ const Graphics::PixelFormat format(2, 5, 6, 5, 0, 11, 5, 0, 0);
// Initialize backend
- initGraphics(800, 600, true);
+ initGraphics(800, 600, true, &format);
+
+ _backgroundSurface.create(800, 600, format);
_isSaveAllowed = false;
diff --git a/engines/fullpipe/fullpipe.h b/engines/fullpipe/fullpipe.h
index 88c9587004..bab7a72a4f 100644
--- a/engines/fullpipe/fullpipe.h
+++ b/engines/fullpipe/fullpipe.h
@@ -73,6 +73,8 @@ public:
void updateEvents();
+ Graphics::Surface _backgroundSurface;
+
CGameLoader *_gameLoader;
GameProject *_gameProject;
bool loadGam(const char *fname);
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp
index 91c07806b0..9bd511e38c 100644
--- a/engines/fullpipe/gfx.cpp
+++ b/engines/fullpipe/gfx.cpp
@@ -31,17 +31,17 @@ namespace Fullpipe {
void Bitmap::load(Common::ReadStream *s) {
debug(5, "Bitmap::load()");
- x = s->readUint32LE();
- y = s->readUint32LE();
- width = s->readUint32LE();
- height = s->readUint32LE();
+ _x = s->readUint32LE();
+ _y = s->readUint32LE();
+ _width = s->readUint32LE();
+ _height = s->readUint32LE();
s->readUint32LE(); // pixels
- type = s->readUint32LE();
- field_18 = s->readUint32LE();
- flags = s->readUint32LE();
+ _type = s->readUint32LE();
+ _field_18 = s->readUint32LE();
+ _flags = s->readUint32LE();
- debug(9, "x: %d y: %d w: %d h: %d", x, y, width, height);
- debug(9, "type: %d field_18: %d flags: 0x%x", type, field_18, flags);
+ debug(8, "Bitmap: x: %d y: %d w: %d h: %d field_18: 0x%x", _x, _y, _width, _height, _field_18);
+ debug(8, "Bitmap: type: %s (0x%04x) flags: 0x%x", Common::tag2string(_type).c_str(), _type, _flags);
}
Background::Background() {
@@ -242,6 +242,11 @@ bool Picture::load(MfcArchive &file) {
file.read(_paletteData, 1024);
}
+ debug(5, "Picture::load: <%s>", _memfilename);
+
+ getData();
+ init();
+
return true;
}
@@ -264,20 +269,27 @@ void Picture::init() {
getDibInfo();
- _bitmap->flags |= 0x1000000;
+ _bitmap->_flags |= 0x1000000;
}
void Picture::getDibInfo() {
int off = _dataSize & ~0xf;
+ debug(0, "Picture::getDibInfo: _dataSize: %d", _dataSize);
+
+ if (!_dataSize) {
+ warning("Picture::getDibInfo(): Empty data size");
+ return;
+ }
+
if (_dataSize != off) {
warning("Uneven data size: 0x%x", _dataSize);
}
- Common::MemoryReadStream *s = new Common::MemoryReadStream(_data + off, 32);
+ Common::MemoryReadStream *s = new Common::MemoryReadStream(_data + off - 32, 32);
_bitmap->load(s);
- _bitmap->pixels = _data;
+ _bitmap->_pixels = _data;
}
Bitmap *Picture::getPixelData() {
@@ -307,7 +319,7 @@ void Picture::draw(int x, int y, int style, int angle) {
warning("Picture:draw: alpha = %0x", _alpha);
}
- if (_bitmap->type == MKTAG('C', 'B', '\0', '\0') || _bitmap->type == MKTAG('R', 'B', '\0', '\0')) {
+ if (_bitmap->_type == MKTAG('C', 'B', '\0', '\0') || _bitmap->_type == MKTAG('R', 'B', '\0', '\0')) {
if (_paletteData) {
warning("Picture:draw: have palette");
}
@@ -326,7 +338,7 @@ void Picture::draw(int x, int y, int style, int angle) {
warning("Picture:draw: angle = %d", angle);
drawRotated(x1, y1, angle);
} else {
- putDib(x1, y1);
+ _bitmap->putDib(x1, y1, _paletteData);
}
}
}
@@ -334,7 +346,237 @@ void Picture::draw(int x, int y, int style, int angle) {
void Picture::drawRotated(int x, int y, int angle) {
}
-void Picture::putDib(int x, int y) {
+void Bitmap::putDib(int x, int y, byte *palette) {
+ byte *curDestPtr;
+ int endy;
+ int pos;
+ byte *srcPtr;
+ uint pixel;
+ int start1;
+ int fillValue;
+ int pixoffset;
+ int end2;
+ int pixelHigh;
+ int pixoffset1;
+ int leftx;
+ uint pixel1;
+ uint pixel1High;
+ int bpp;
+ uint pitch;
+ byte *srcPtr1;
+ int end;
+ int endx;
+ int endy1;
+ bool cb05_format;
+ byte *pixPtr;
+ byte *srcPtr2;
+ int start;
+
+ endx = _width + _x - 1;
+ endy = _height + _y - 1;
+
+ if (_x > 799 || _width + _x - 1 < 0 || _y > 599 || endy < 0)
+ return;
+
+ if (endy > 599)
+ endy = 599;
+
+ if (_type == MKTAG('R', 'B', '\0', '\0')) {
+ endy1 = endy;
+ pixPtr = _pixels;
+ pos = _x;
+
+ LABEL_17:
+ srcPtr = pixPtr;
+ while (1) {
+ while (1) {
+ while (1) {
+ while (1) {
+ while (1) {
+ pixel = *(int16 *)srcPtr;
+ srcPtr += 2;
+ pixPtr = srcPtr;
+ if (pixel)
+ break;
+ --endy1;
+ if (endy1 < _y)
+ return;
+ pos = _x;
+ }
+
+ if (pixel == 0x100)
+ return;
+
+ if (pixel != 0x200)
+ break;
+
+ pixel1 = *(int16 *)srcPtr;
+ srcPtr += 2;
+ pos += (byte)pixel1;
+ pixel1High = pixel1 >> 8;
+
+ if (pixel1High) {
+ endy1 -= pixel1High;
+
+ if (endy1 < _y)
+ return;
+ }
+ }
+ start1 = pos;
+ fillValue = (byte)pixel;
+
+ if (!(byte)pixel)
+ break;
+
+ pos += (byte)pixel;
+ pixoffset = -start1;
+
+ if (pixoffset <= 0)
+ goto LABEL_25;
+
+ fillValue = (byte)pixel - pixoffset;
+
+ if (fillValue > 0) {
+ start1 = 0;
+
+ LABEL_25:
+ end2 = 799;
+ if (pos <= end2 + 1 || (fillValue += end2 - pos + 1, fillValue > 0)) {
+ if (endy1 <= endy) {
+ curDestPtr = (byte *)g_fullpipe->_backgroundSurface.getBasePtr(endy1, start1);
+ int bgcolor = *(int32 *)(palette + 4 * (pixel >> 8));
+
+ colorFill(curDestPtr, fillValue, bgcolor);
+ }
+ goto LABEL_17;
+ }
+ }
+ }
+ pixelHigh = pixel >> 8;
+ srcPtr2 = srcPtr;
+ pos += pixelHigh;
+ srcPtr += 2 * ((pixelHigh + 1) >> 1);
+ pixoffset1 = -start1;
+
+ if (pixoffset1 > 0)
+ break;
+
+ LABEL_37:
+ leftx = 799;
+ if (pos > leftx + 1) {
+ pixelHigh += leftx - pos + 1;
+ if (pixelHigh <= 0)
+ continue;
+ }
+ if (endy1 <= endy) {
+ curDestPtr = (byte *)g_fullpipe->_backgroundSurface.getBasePtr(endy1, start1);
+ paletteFill(curDestPtr, srcPtr2, pixelHigh);
+ }
+ }
+ pixelHigh -= pixoffset1;
+ if (pixelHigh > 0) {
+ start1 = 0;
+ srcPtr2 += pixoffset1;
+ goto LABEL_37;
+ }
+ }
+ }
+
+ cb05_format = (_type == MKTAG('C', 'B', '\05', 'e'));
+ bpp = cb05_format ? 2 : 1;
+ end = _width + _x - 1;
+ pitch = (bpp * (endx - _x + 1) + 3) & 0xFFFFFFFC;
+ start = _x;
+ srcPtr1 = &_pixels[pitch * (endy - _y)];
+ if (_x < 0) {
+ srcPtr1 += bpp * -_x;
+ start = 0;
+ }
+
+ if (endx > 799)
+ end = 799;
+
+ if (_flags & 0x1000000) {
+ for (int n = _y; n < endy; srcPtr1 -= pitch) {
+ curDestPtr = (byte *)g_fullpipe->_backgroundSurface.getBasePtr(n, start);
+ copierKeyColor(curDestPtr, srcPtr1, end - start + 1, _flags & 0xff);
+ ++n;
+ }
+ } else {
+ for (int n = _y; n <= endy; srcPtr1 -= pitch) {
+ curDestPtr = (byte *)g_fullpipe->_backgroundSurface.getBasePtr(n, start);
+ copier(curDestPtr, srcPtr1, end - start + 1);
+ ++n;
+ }
+ }
+}
+
+ void Bitmap::colorFill(byte *dest, int len, int color) {
+#if 0
+ if (blendMode) {
+ if (blendMode != 1)
+ error("vrtPutDib : RLE Fill : Invalid alpha blend mode");
+
+ colorFill = ptralphaFillColor16bit;
+ } else {
+ colorFill = ptrfillColor16bit;
+ }
+#endif
+
+}
+
+void Bitmap::paletteFill(byte *dest, byte *src, int len) {
+#if 0
+ if (blendMode) {
+ if (blendMode != 1)
+ error("vrtPutDib : RLE Fill : Invalid alpha blend mode");
+
+ paletteFill = ptrcopierWithPaletteAlpha;
+ } else {
+ paletteFill = ptrcopierWithPalette;
+ }
+#endif
+
+}
+
+void Bitmap::copierKeyColor(byte *dest, byte *src, int len, int keyColor) {
+#if 0
+ if (blendMode) {
+ if (blendMode == 1) {
+ if (cb05_format)
+ copierKeyColor = ptrcopier16bitKeycolorAlpha;
+ else
+ copierKeyColor = ptrcopierKeycolorAlpha;
+ } else {
+ copier = 0;
+ }
+ } else if (cb05_format) {
+ copierKeyColor = ptrcopier16bitKeycolor;
+ } else {
+ copierKeyColor = ptrkeyColor16bit;
+ }
+#endif
+
+}
+
+void Bitmap::copier(byte *dest, byte *src, int len) {
+#if 0
+ if (blendMode) {
+ if (blendMode == 1) {
+ if (cb05_format)
+ copier = ptrcopier16bitAlpha;
+ else
+ copier = ptrcopierWithPaletteAlpha;
+ } else {
+ copier = 0;
+ }
+ } else if (cb05_format) {
+ copier = ptrcopier16bit;
+ } else {
+ copier = ptrcopierWithPalette;
+ }
+#endif
+
}
BigPicture::BigPicture() {
diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h
index a2bcad01b8..1205468b6f 100644
--- a/engines/fullpipe/gfx.h
+++ b/engines/fullpipe/gfx.h
@@ -32,16 +32,22 @@ class ShadowsItemArray : public CObArray {
};
struct Bitmap {
- int x;
- int y;
- int width;
- int height;
- byte *pixels;
- int type;
- int field_18;
- int flags;
+ int _x;
+ int _y;
+ int _width;
+ int _height;
+ byte *_pixels;
+ int _type;
+ int _field_18;
+ int _flags;
void load(Common::ReadStream *s);
+ void putDib(int x, int y, byte *palette);
+
+ void colorFill(byte *dest, int len, int color);
+ void paletteFill(byte *dest, byte *src, int len);
+ void copierKeyColor(byte *dest, byte *src, int len, int keyColor);
+ void copier(byte *dest, byte *src, int len);
};
class Picture : public MemoryObject {
@@ -69,7 +75,6 @@ class Picture : public MemoryObject {
Bitmap *getPixelData();
void draw(int x, int y, int style, int angle);
void drawRotated(int x, int y, int angle);
- void putDib(int x, int y);
byte getAlpha() { return (byte)_alpha; }
void setAlpha(byte alpha) { _alpha = alpha; }
diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp
index 43b8e11f8f..e1b2b331d9 100644
--- a/engines/fullpipe/sound.cpp
+++ b/engines/fullpipe/sound.cpp
@@ -88,8 +88,8 @@ bool Sound::load(MfcArchive &file, NGIArchive *archive) {
_objectId = file.readUint16LE();
- if (archive && archive->hasFile(_filename)) {
- Common::SeekableReadStream *s = archive->createReadStreamForMember(_filename);
+ if (archive && archive->hasFile(_memfilename)) {
+ Common::SeekableReadStream *s = archive->createReadStreamForMember(_memfilename);
_soundData = (byte *)calloc(s->size(), 1);
diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp
index e01d08e20e..d1f9e00a6a 100644
--- a/engines/fullpipe/stateloader.cpp
+++ b/engines/fullpipe/stateloader.cpp
@@ -44,7 +44,7 @@ bool FullpipeEngine::loadGam(const char *fname) {
_inventory->setItemFlags(ANI_INV_MAP, 0x10003);
_inventory->addItem(ANI_INV_MAP, 1);
-#if 0
+#if 1
g_fullpipe->accessScene(301);
g_fullpipe->accessScene(302);
g_fullpipe->accessScene(303);
diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp
index cdb8fabf46..4a2616ca91 100644
--- a/engines/fullpipe/statics.cpp
+++ b/engines/fullpipe/statics.cpp
@@ -145,7 +145,7 @@ bool Statics::load(MfcArchive &file) {
_staticsId = file.readUint16LE();
_stringObj = file.readPascalString();
- debug(7, "statics: <%s>", _stringObj);
+ debug(7, "statics: <%s>", transCyrillic((byte *)_stringObj));
_picture = new Picture();
_picture->load(file);
diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp
index 78440d8d53..6ca6a8e6b9 100644
--- a/engines/fullpipe/utils.cpp
+++ b/engines/fullpipe/utils.cpp
@@ -108,7 +108,7 @@ char *MfcArchive::readPascalString(bool twoByte) {
}
MemoryObject::MemoryObject() {
- _filename = 0;
+ _memfilename = 0;
_field_8 = 0;
_field_C = 0;
_field_10 = -1;
@@ -121,7 +121,14 @@ MemoryObject::MemoryObject() {
bool MemoryObject::load(MfcArchive &file) {
debug(5, "MemoryObject::load()");
- _filename = file.readPascalString();
+ _memfilename = file.readPascalString();
+
+ if (char *p = strchr(_memfilename, '\\')) {
+ for (char *d = _memfilename; *p;) {
+ p++;
+ *d++ = *p;
+ }
+ }
if (g_fullpipe->_currArchive) {
_field_14 = 0;
@@ -170,8 +177,10 @@ bool MemoryObject2::load(MfcArchive &file) {
_flags |= 1;
- if (_filename) {
- MemoryObject::loadFile(_filename);
+ debug(5, "MemoryObject2::load: <%s>", _memfilename);
+
+ if (_memfilename && *_memfilename) {
+ MemoryObject::loadFile(_memfilename);
}
return true;
diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h
index 7314eadb60..524436bd1e 100644
--- a/engines/fullpipe/utils.h
+++ b/engines/fullpipe/utils.h
@@ -81,7 +81,7 @@ class MemoryObject : CObject {
friend class Picture;
protected:
- char *_filename;
+ char *_memfilename;
int _field_8;
int _field_C;
int _field_10;
@@ -98,7 +98,7 @@ class MemoryObject : CObject {
MemoryObject();
virtual bool load(MfcArchive &file);
void loadFile(char *filename);
- void load() { loadFile(_filename); }
+ void load() { loadFile(_memfilename); }
byte *getData();
};