aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/fullpipe/gfx.cpp74
-rw-r--r--engines/fullpipe/gfx.h16
-rw-r--r--engines/fullpipe/objects.h10
-rw-r--r--engines/fullpipe/stateloader.cpp54
-rw-r--r--engines/fullpipe/statics.cpp105
-rw-r--r--engines/fullpipe/statics.h13
-rw-r--r--engines/fullpipe/utils.cpp43
-rw-r--r--engines/fullpipe/utils.h10
8 files changed, 288 insertions, 37 deletions
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp
index a4dec6969e..252333e1f0 100644
--- a/engines/fullpipe/gfx.cpp
+++ b/engines/fullpipe/gfx.cpp
@@ -225,6 +225,44 @@ Picture::Picture() {
_convertedBitmap = 0;
}
+Picture::~Picture() {
+ freePicture();
+
+ _bitmap = 0;
+
+ if (_memoryObject2)
+ delete _memoryObject2;
+
+ if (_paletteData)
+ free(_paletteData);
+
+ if (_convertedBitmap) {
+ delete _convertedBitmap;
+ _convertedBitmap = 0;
+ }
+}
+
+void Picture::freePicture() {
+ if (_bitmap) {
+ if (testFlags() && !_field_54) {
+ freeData();
+ delete _bitmap;
+ _bitmap = 0;
+ }
+ }
+
+ if (_bitmap) {
+ _bitmap = 0;
+ _data = 0;
+ }
+
+ if (_convertedBitmap) {
+ free(_convertedBitmap->_pixels);
+ delete _convertedBitmap;
+ _convertedBitmap = 0;
+ }
+}
+
bool Picture::load(MfcArchive &file) {
debug(5, "Picture::load()");
MemoryObject::load(file);
@@ -350,22 +388,21 @@ void Picture::draw(int x, int y, int style, int angle) {
switch (style) {
case 1:
//flip
- warning("Picture::draw: style 1");
+ warning("STUB: Picture::draw: style 1");
break;
case 2:
- error("Picture::draw: style 2");
+ error("STUB: Picture::draw: style 2");
break;
default:
- if (angle) {
- warning("Picture:draw: angle = %d", angle);
+ if (angle)
drawRotated(x1, y1, angle);
- } else {
+ else
_bitmap->putDib(x1, y1, (int32 *)_paletteData);
- }
}
}
void Picture::drawRotated(int x, int y, int angle) {
+ warning("STUB: Picture::drawRotated(%d, %d, %d)", x, y, angle);
}
void Picture::displayPicture() {
@@ -399,6 +436,26 @@ void Picture::displayPicture() {
}
}
+void Picture::setPaletteData(byte *pal) {
+ if (_paletteData)
+ free(_paletteData);
+
+ if (pal) {
+ _paletteData = (byte *)malloc(1024);
+ memcpy(_paletteData, pal, 1024);
+ }
+}
+
+void Picture::copyMemoryObject2(Picture *src) {
+ if (_width == src->_width && _height == src->_height) {
+ if (src->_memoryObject2 && src->_memoryObject2->_rows && _memoryObject2) {
+ byte *data = loadData();
+ _memoryObject2->copyData(data, _dataSize);
+ setAOIDs();
+ }
+ }
+}
+
void Bitmap::putDib(int x, int y, int32 *palette) {
debug(0, "Bitmap::putDib(%d, %d)", x, y);
@@ -677,7 +734,10 @@ void Bitmap::copier(uint16 *dest, byte *src, int len, int32 *palette, bool cb05_
}
}
-BigPicture::BigPicture() {
+Bitmap *Bitmap::reverseImage() {
+ warning("STUB: Bitmap::reverseImage()");
+
+ return this;
}
bool BigPicture::load(MfcArchive &file) {
diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h
index 8a14177dc0..36ec1bd8d9 100644
--- a/engines/fullpipe/gfx.h
+++ b/engines/fullpipe/gfx.h
@@ -53,13 +53,16 @@ struct Bitmap {
void paletteFill(uint16 *dest, byte *src, int len, int32 *palette);
void copierKeyColor(uint16 *dest, byte *src, int len, int keyColor, int32 *palette, bool cb05_format);
void copier(uint16 *dest, byte *src, int len, int32 *palette, bool cb05_format);
+
+ Bitmap *reverseImage();
};
class Picture : public MemoryObject {
friend class Movement;
+ friend class DynamicPhase;
Common::Rect _rect;
- int _convertedBitmap;
+ Bitmap *_convertedBitmap;
int _x;
int _y;
int _field_44;
@@ -75,6 +78,10 @@ class Picture : public MemoryObject {
public:
Picture();
+ virtual ~Picture();
+
+ void freePicture();
+
virtual bool load(MfcArchive &file);
void setAOIDs();
void init();
@@ -87,11 +94,16 @@ class Picture : public MemoryObject {
void setAlpha(byte alpha) { _alpha = alpha; }
Common::Point *getDimensions(Common::Point *p);
+
+ byte *getPaletteData() { return _paletteData; }
+ void setPaletteData(byte *pal);
+
+ void copyMemoryObject2(Picture *src);
};
class BigPicture : public Picture {
public:
- BigPicture();
+ BigPicture() {}
virtual bool load(MfcArchive &file);
};
diff --git a/engines/fullpipe/objects.h b/engines/fullpipe/objects.h
index 65113a9bcf..9acedc98e0 100644
--- a/engines/fullpipe/objects.h
+++ b/engines/fullpipe/objects.h
@@ -143,7 +143,7 @@ union VarValue {
char *stringValue;
};
-class Message {
+class Message : public CObject {
public:
int _messageKind;
int16 _parentId;
@@ -161,17 +161,19 @@ class Message {
public:
Message();
+ Message(Message *src);
};
-class ExCommand : public CObject {
- Message _msg;
+class ExCommand : public Message {
int _messageNum;
int _field_3C;
- int _flags;
+ int _excFlags;
int _parId;
public:
ExCommand();
+ ExCommand(ExCommand *src);
+ virtual ~ExCommand() {}
virtual bool load(MfcArchive &file);
};
diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp
index 32970a92ba..c1da2d5997 100644
--- a/engines/fullpipe/stateloader.cpp
+++ b/engines/fullpipe/stateloader.cpp
@@ -213,33 +213,41 @@ bool CInteraction::load(MfcArchive &file) {
ExCommand::ExCommand() {
_field_3C = 1;
_messageNum = 0;
- _flags = 0;
+ _excFlags = 0;
_parId = 0;
}
+ExCommand::ExCommand(ExCommand *src) : Message(src) {
+ _field_3C = 1;
+ _messageNum = src->_messageNum;
+ _excFlags = src->_excFlags;
+ _parId = src->_parId;
+
+}
+
bool ExCommand::load(MfcArchive &file) {
debug(5, "ExCommand::load()");
- _msg._parentId = file.readUint16LE();
- _msg._messageKind = file.readUint32LE();
- _msg._x = file.readUint32LE();
- _msg._y = file.readUint32LE();
- _msg._field_14 = file.readUint32LE();
- _msg._sceneClickX = file.readUint32LE();
- _msg._sceneClickY = file.readUint32LE();
- _msg._field_20 = file.readUint32LE();
- _msg._field_24 = file.readUint32LE();
- _msg._param28 = file.readUint32LE();
- _msg._field_2C = file.readUint32LE();
- _msg._field_30 = file.readUint32LE();
- _msg._field_34 = file.readUint32LE();
+ _parentId = file.readUint16LE();
+ _messageKind = file.readUint32LE();
+ _x = file.readUint32LE();
+ _y = file.readUint32LE();
+ _field_14 = file.readUint32LE();
+ _sceneClickX = file.readUint32LE();
+ _sceneClickY = file.readUint32LE();
+ _field_20 = file.readUint32LE();
+ _field_24 = file.readUint32LE();
+ _param28 = file.readUint32LE();
+ _field_2C = file.readUint32LE();
+ _field_30 = file.readUint32LE();
+ _field_34 = file.readUint32LE();
_messageNum = file.readUint32LE();
_field_3C = 0;
if (g_fullpipe->_gameProjectVersion >= 12) {
- _flags = file.readUint32LE();
+ _excFlags = file.readUint32LE();
_parId = file.readUint32LE();
}
@@ -262,6 +270,22 @@ Message::Message() {
_field_34 = 0;
}
+Message::Message(Message *src) {
+ _parentId = src->_parentId;
+ _messageKind = src->_messageKind;
+ _x = src->_x;
+ _y = src->_y;
+ _field_14 = src->_field_14;
+ _sceneClickX = src->_sceneClickX;
+ _sceneClickY = src->_sceneClickY;
+ _field_20 = src->_field_20;
+ _field_24 = src->_field_24;
+ _param28 = src->_param28;
+ _field_2C = src->_field_2C;
+ _field_30 = src->_field_30;
+ _field_34 = src->_field_34;
+}
+
CObjstateCommand::CObjstateCommand() {
_value = 0;
}
diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp
index 0f5b861efa..7d91a11eda 100644
--- a/engines/fullpipe/statics.cpp
+++ b/engines/fullpipe/statics.cpp
@@ -28,6 +28,7 @@
#include "fullpipe/messagequeue.h"
#include "fullpipe/gameobj.h"
+#include "fullpipe/objectnames.h"
namespace Fullpipe {
@@ -205,10 +206,16 @@ void StaticANIObject::loadMovementsPixelData() {
((Movement *)_movements[i])->loadPixelData();
}
-Statics *StaticANIObject::addStatics(Statics *ani) {
- warning("STUB: StaticANIObject::addStatics");
+Statics *StaticANIObject::addReverseStatics(Statics *st) {
+ Statics *res = getStaticsById(st->_staticsId ^ 0x4000);
- return 0;
+ if (!res) {
+ res = new Statics(st, true);
+
+ _staticsList.push_back(res);
+ }
+
+ return res;
}
void StaticANIObject::draw() {
@@ -234,6 +241,27 @@ void StaticANIObject::draw2() {
Statics::Statics() {
_staticsId = 0;
_picture = 0;
+ _staticsName = 0;
+}
+
+Statics::Statics(Statics *src, bool reverse) : DynamicPhase(src, reverse) {
+ _staticsId = src->_staticsId;
+
+ if (reverse) {
+ _staticsId ^= 0x4000;
+ int newlen = strlen(src->_staticsName) + strlen(sO_MirroredTo) + 1;
+ _staticsName = (char *)calloc(newlen, 1);
+
+ snprintf(_staticsName, newlen, "%s%s", sO_MirroredTo, src->_staticsName);
+ } else {
+ _staticsName = (char *)calloc(strlen(src->_staticsName) + 1, 1);
+ strncpy(_staticsName, src->_staticsName, strlen(src->_staticsName) + 1);
+ }
+
+ _memfilename = (char *)calloc(strlen(src->_memfilename) + 1, 1);
+ strncpy(_memfilename, src->_memfilename, strlen(src->_memfilename) + 1);
+
+ _picture = new Picture();
}
bool Statics::load(MfcArchive &file) {
@@ -314,7 +342,7 @@ bool Movement::load(MfcArchive &file, StaticANIObject *ani) {
if (!_staticsObj1 && (staticsid & 0x4000)) {
Statics *s = ani->getStaticsById(staticsid ^ 0x4000);
- _staticsObj1 = ani->addStatics(s);
+ _staticsObj1 = ani->addReverseStatics(s);
}
_mx = file.readUint32LE();
@@ -326,7 +354,7 @@ bool Movement::load(MfcArchive &file, StaticANIObject *ani) {
if (!_staticsObj2 && (staticsid & 0x4000)) {
Statics *s = ani->getStaticsById(staticsid ^ 0x4000);
- _staticsObj2 = ani->addStatics(s);
+ _staticsObj2 = ani->addReverseStatics(s);
}
_m2x = file.readUint32LE();
@@ -406,10 +434,73 @@ DynamicPhase::DynamicPhase() {
_someX = 0;
_rect = 0;
_field_7C = 0;
- _flags = 0;
+ _dynFlags = 0;
_someY = 0;
}
+DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) {
+ _field_7C = src->_field_7C;
+ _rect = new Common::Rect();
+
+ if (reverse) {
+ if (!src->_bitmap)
+ src->init();
+
+ _bitmap = src->_bitmap->reverseImage();
+ _data = _bitmap->_pixels;
+ _dataSize = src->_dataSize;
+
+ if (g_fullpipe->_currArchive) {
+ _field_14 = 0;
+ _libHandle = g_fullpipe->_currArchive;
+ }
+
+ _flags |= 1;
+
+ _someX = src->_someX;
+ _someY = src->_someY;
+ } else {
+ _field_14 = src->_field_14;
+ _field_8 = src->_field_8;
+ _flags = src->_flags;
+
+ _memfilename = (char *)calloc(strlen(src->_memfilename) + 1, 1);
+ strncpy(_memfilename, src->_memfilename, strlen(src->_memfilename) + 1);
+ _dataSize = src->_dataSize;
+ _field_10 = src->_field_10;
+ _libHandle = src->_libHandle;
+
+ _bitmap = src->_bitmap;
+ if (_bitmap)
+ _field_54 = 1;
+
+ _someX = src->_someX;
+ _someY = src->_someY;
+ }
+
+ _rect->top = src->_rect->top;
+ _rect->bottom = src->_rect->bottom;
+ _rect->left = src->_rect->left;
+ _rect->right = src->_rect->right;
+
+ _width = src->_width;
+ _height = src->_height;
+ _field_7C = src->_field_7C;
+
+ if (src->getExCommand())
+ _exCommand = new ExCommand(src->getExCommand());
+ else
+ _exCommand = 0;
+
+ _initialCountdown = src->_initialCountdown;
+ _field_6A = src->_field_6A;
+ _dynFlags = src->_dynFlags;
+
+ setPaletteData(getPaletteData());
+
+ copyMemoryObject2(src);
+}
+
bool DynamicPhase::load(MfcArchive &file) {
debug(5, "DynamicPhase::load()");
@@ -429,7 +520,7 @@ bool DynamicPhase::load(MfcArchive &file) {
assert (g_fullpipe->_gameProjectVersion >= 12);
- _flags = file.readUint32LE();
+ _dynFlags = file.readUint32LE();
return true;
}
diff --git a/engines/fullpipe/statics.h b/engines/fullpipe/statics.h
index 0ae5e6111a..128f0f522e 100644
--- a/engines/fullpipe/statics.h
+++ b/engines/fullpipe/statics.h
@@ -43,6 +43,8 @@ class CStepArray : public CObject {
};
class StaticPhase : public Picture {
+ friend class DynamicPhase;
+
int16 _initialCountdown;
int16 _countdown;
int16 _field_68;
@@ -51,7 +53,10 @@ class StaticPhase : public Picture {
public:
StaticPhase();
+
virtual bool load(MfcArchive &file);
+
+ ExCommand *getExCommand() { return _exCommand; }
};
class DynamicPhase : public StaticPhase {
@@ -63,10 +68,12 @@ class DynamicPhase : public StaticPhase {
Common::Rect *_rect;
int16 _field_7C;
int16 _field_7E;
- int _flags;
+ int _dynFlags;
public:
DynamicPhase();
+ DynamicPhase(DynamicPhase *src, bool reverse);
+
virtual bool load(MfcArchive &file);
};
@@ -81,6 +88,8 @@ class Statics : public DynamicPhase {
public:
Statics();
+ Statics(Statics *src, bool reverse);
+
virtual bool load(MfcArchive &file);
Statics *getStaticsById(int itemId);
@@ -171,7 +180,7 @@ class StaticANIObject : public GameObject {
void loadMovementsPixelData();
- Statics *addStatics(Statics *ani);
+ Statics *addReverseStatics(Statics *ani);
void draw();
void draw2();
};
diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp
index 3e153c1801..ec6b59029b 100644
--- a/engines/fullpipe/utils.cpp
+++ b/engines/fullpipe/utils.cpp
@@ -120,6 +120,12 @@ MemoryObject::MemoryObject() {
_data = 0;
}
+MemoryObject::~MemoryObject() {
+ freeData();
+ if (_memfilename)
+ free(_memfilename);
+}
+
bool MemoryObject::load(MfcArchive &file) {
debug(5, "MemoryObject::load()");
_memfilename = file.readPascalString();
@@ -168,10 +174,37 @@ byte *MemoryObject::getData() {
}
}
+byte *MemoryObject::loadData() {
+ load();
+ return _data;
+}
+
+void MemoryObject::freeData() {
+ if (_data)
+ free(_data);
+
+ _data = 0;
+}
+
+bool MemoryObject::testFlags() {
+ if (_field_8)
+ return false;
+
+ if (_flags & 1)
+ return true;
+
+ return false;
+}
+
MemoryObject2::MemoryObject2() {
_rows = 0;
}
+MemoryObject2::~MemoryObject2() {
+ if (_rows)
+ free(_rows);
+}
+
bool MemoryObject2::load(MfcArchive &file) {
debug(5, "MemoryObject2::load()");
MemoryObject::load(file);
@@ -187,6 +220,16 @@ bool MemoryObject2::load(MfcArchive &file) {
return true;
}
+void MemoryObject2::copyData(byte *src, int dataSize) {
+ if (_data)
+ freeData();
+
+ _dataSize = dataSize;
+ _data = (byte *)malloc(dataSize);
+
+ memcpy(_data, src, _dataSize);
+}
+
int MfcArchive::readCount() {
int count = readUint16LE();
diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h
index 524436bd1e..70a057c82a 100644
--- a/engines/fullpipe/utils.h
+++ b/engines/fullpipe/utils.h
@@ -96,10 +96,17 @@ class MemoryObject : CObject {
public:
MemoryObject();
+ virtual ~MemoryObject();
+
virtual bool load(MfcArchive &file);
void loadFile(char *filename);
void load() { loadFile(_memfilename); }
byte *getData();
+ byte *loadData();
+
+ bool testFlags();
+
+ void freeData();
};
class MemoryObject2 : public MemoryObject {
@@ -110,7 +117,10 @@ class MemoryObject2 : public MemoryObject {
public:
MemoryObject2();
+ virtual ~MemoryObject2();
virtual bool load(MfcArchive &file);
+
+ void copyData(byte *src, int dataSize);
};
class CObArray : public Common::Array<CObject>, public CObject {