aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorwhitertandrek2018-03-27 13:53:03 +0300
committerEugene Sandulenko2018-06-28 23:51:32 +0200
commitc37bd09354cb233404bec5aed6ded79412650cef (patch)
tree015edd054870708458b653a473809b4f835d15d4 /engines
parent17c2bcfb948a24f9a1d99eeac85f799d45549d9f (diff)
downloadscummvm-rg350-c37bd09354cb233404bec5aed6ded79412650cef.tar.gz
scummvm-rg350-c37bd09354cb233404bec5aed6ded79412650cef.tar.bz2
scummvm-rg350-c37bd09354cb233404bec5aed6ded79412650cef.zip
PINK: implemented drawing of transparent drawing, but it seems that original handles this a bit different.(intro of Peril first sprite keeps transparent colour index somewhere else)
Diffstat (limited to 'engines')
-rw-r--r--engines/pink/cel_decoder.cpp65
-rw-r--r--engines/pink/cel_decoder.h8
-rw-r--r--engines/pink/director.cpp44
-rw-r--r--engines/pink/director.h5
-rw-r--r--engines/pink/objects/actions/action_cel.cpp2
-rw-r--r--engines/pink/objects/actions/action_loop.h2
-rw-r--r--engines/pink/objects/actions/action_still.cpp4
-rw-r--r--engines/pink/objects/actors/lead_actor.cpp1
-rw-r--r--engines/pink/objects/module.cpp4
-rw-r--r--engines/pink/objects/pages/game_page.cpp1
10 files changed, 102 insertions, 34 deletions
diff --git a/engines/pink/cel_decoder.cpp b/engines/pink/cel_decoder.cpp
index 7e7a9939e9..82dca7bee3 100644
--- a/engines/pink/cel_decoder.cpp
+++ b/engines/pink/cel_decoder.cpp
@@ -64,15 +64,23 @@ uint32 CelDecoder::getY() {
return track->getY();
}
-Graphics::Surface *CelDecoder::getCurrentFrame() {
+
+uint16 CelDecoder::getTransparentColourIndex() {
+ CelVideoTrack *track = (CelVideoTrack*) getTrack(0);
+ if (!track)
+ return 0;
+ return track->getTransparentColourIndex();
+}
+
+const Graphics::Surface *CelDecoder::getCurrentFrame() {
CelVideoTrack *track = (CelVideoTrack*) getTrack(0);
if (!track)
- return nullptr;
- return nullptr;
+ return 0;
+ return track->getCurrentFrame();
}
CelDecoder::CelVideoTrack::CelVideoTrack(Common::SeekableReadStream *stream, uint16 frameCount, uint16 width, uint16 height, bool skipHeader)
- : FlicVideoTrack(stream, frameCount, width, height, 1) {
+ : FlicVideoTrack(stream, frameCount, width, height, 1), _center(0,0), _transparentColourIndex(0){
readHeader();
}
@@ -86,22 +94,33 @@ void CelDecoder::CelVideoTrack::readPrefixChunk() {
if (chunkType != PREFIX_TYPE)
return;
uint32 offset = 6;
- while (offset < chunkSize) {
- uint32 subchunkSize = _fileStream->readUint32LE();
- uint16 subchunkType = _fileStream->readUint16LE();
- switch (subchunkType) {
- case CEL_DATA:
- _fileStream->skip(2); // Unknown field
- _center.x = _fileStream->readUint16LE();
- _center.y = _fileStream->readUint16LE();
- _fileStream->skip(subchunkSize - 6 - 6);
- break;
- default:
- _fileStream->skip(subchunkSize - 6);
- break;
- }
- offset += subchunkSize;
+
+ uint32 subchunkSize = _fileStream->readUint32LE();
+ uint16 subchunkType = _fileStream->readUint16LE();
+
+ switch (subchunkType) {
+ case CEL_DATA:
+ debug("%u", _fileStream->readUint16LE());
+ _center.x = _fileStream->readUint16LE();
+ _center.y = _fileStream->readUint16LE();
+ debug("stretch x: %u", _fileStream->readUint16LE());
+ debug("stretch y: %u", _fileStream->readUint16LE());
+ debug("rotation x: %u", _fileStream->readUint16LE());
+ debug("rotation y: %u", _fileStream->readUint16LE());
+ debug("rotation z: %u", _fileStream->readUint16LE());
+ debug("current Frame: %u", _fileStream->readUint16LE());
+ debug("next frame offset: %u",_fileStream->readUint32LE());
+ debug("tcolor: %u", _transparentColourIndex = _fileStream->readUint16LE());
+ for (int j = 0; j < 18; ++j) {
+ debug("%u", _fileStream->readUint16LE());
+ }
+ break;
+ default:
+ error("Unknown subchunk type");
+ _fileStream->skip(subchunkSize - 6);
+ break;
}
+
}
void CelDecoder::CelVideoTrack::readHeader() {
@@ -130,4 +149,12 @@ uint32 CelDecoder::CelVideoTrack::getY() const {
return _center.y - getHeight() / 2;
}
+uint16 CelDecoder::CelVideoTrack::getTransparentColourIndex() {
+ return _transparentColourIndex;
+}
+
+const Graphics::Surface *CelDecoder::CelVideoTrack::getCurrentFrame() {
+ return _surface;
+}
+
} // End of namepsace Pink \ No newline at end of file
diff --git a/engines/pink/cel_decoder.h b/engines/pink/cel_decoder.h
index ef43e809f8..3ccea1a52a 100644
--- a/engines/pink/cel_decoder.h
+++ b/engines/pink/cel_decoder.h
@@ -32,8 +32,8 @@ class CelDecoder : public Video::FlicDecoder {
public:
uint32 getX();
uint32 getY();
-
- Graphics::Surface *getCurrentFrame();
+ uint16 getTransparentColourIndex();
+ const Graphics::Surface *getCurrentFrame();
virtual bool loadStream(Common::SeekableReadStream *stream);
@@ -46,8 +46,12 @@ protected:
uint32 getX() const;
uint32 getY() const;
+ uint16 getTransparentColourIndex();
+ const Graphics::Surface *getCurrentFrame();
+
private:
void readPrefixChunk();
+ uint16 _transparentColourIndex;
Common::Point _center;
};
};
diff --git a/engines/pink/director.cpp b/engines/pink/director.cpp
index 18ec0b2a00..a7ed2f83d9 100644
--- a/engines/pink/director.cpp
+++ b/engines/pink/director.cpp
@@ -23,7 +23,7 @@
#include "director.h"
#include <engines/pink/objects/actions/action_sound.h>
#include <engines/pink/objects/actions/action_cel.h>
-#include "graphics/surface.h"
+#include <graphics/managed_surface.h>
#include "graphics/palette.h"
#include "cel_decoder.h"
@@ -32,21 +32,41 @@ Director::Director(OSystem *system)
: _system(system) {}
void Director::draw() {
- bool needUpdate = 0;
for (int i = 0; i < _sprites.size(); ++i) {
CelDecoder *decoder = _sprites[i]->getDecoder();
- if (decoder->needsUpdate()) {
- const Graphics::Surface *surface = decoder->decodeNextFrame();
- _system->copyRectToScreen(surface->getPixels(), surface->pitch,
- decoder->getX(), decoder->getY(),
- surface->w, surface->h);
- needUpdate = 1;
+ drawSprite(decoder);
+ }
+ _system->updateScreen();
+}
+
+void Director::drawSprite(CelDecoder *decoder) {
+ const Graphics::Surface *surface;
+ if (decoder->needsUpdate())
+ surface = decoder->decodeNextFrame();
+ else surface = decoder->getCurrentFrame();
+
+
+
+ uint16 colourIndex = decoder->getTransparentColourIndex();
+ if (colourIndex != 0) {
+ Graphics::Surface *screen = _system->lockScreen();
+ for (int y = 0; y < decoder->getHeight(); ++y) {
+ for (int x = 0; x < decoder->getWidth(); ++x) {
+ byte spritePixelColourIndex = *(byte*)surface->getBasePtr(x, y);
+ if (spritePixelColourIndex != colourIndex || spritePixelColourIndex == 1) {
+ *(byte *) screen->getBasePtr(decoder->getX() + x, decoder->getY() + y) = spritePixelColourIndex;
+ }
+ }
}
+ _system->unlockScreen();
}
- if (needUpdate)
- _system->updateScreen();
+ else _system->copyRectToScreen(surface->getPixels(), surface->pitch,
+ decoder->getX(), decoder->getY(),
+ surface->w, surface->h);
+
}
+
void Director::addSprite(ActionCEL *sprite) {
_sprites.push_back(sprite);
int i;
@@ -91,4 +111,8 @@ void Director::removeSound(ActionSound *sound) {
}
}
+void Director::clear() {
+ _sprites.clear();
+}
+
} \ No newline at end of file
diff --git a/engines/pink/director.h b/engines/pink/director.h
index ac88bce52c..ce7d96f874 100644
--- a/engines/pink/director.h
+++ b/engines/pink/director.h
@@ -30,6 +30,7 @@ namespace Pink {
class ActionCEL;
class ActionSound;
+class CelDecoder;
class Director {
public:
@@ -46,7 +47,11 @@ public:
void addSound(ActionSound* sound);
void removeSound(ActionSound* sound);
+ void clear();
private:
+ void drawSprite(CelDecoder *decoder);
+
+
OSystem *_system;
Common::Array<ActionCEL*> _sprites;
Common::Array<ActionSound*> _sounds;
diff --git a/engines/pink/objects/actions/action_cel.cpp b/engines/pink/objects/actions/action_cel.cpp
index dc18ee3a39..312ae31a1d 100644
--- a/engines/pink/objects/actions/action_cel.cpp
+++ b/engines/pink/objects/actions/action_cel.cpp
@@ -43,6 +43,8 @@ void ActionCEL::deserialize(Archive &archive) {
void ActionCEL::start(bool unk) {
if (!_decoder)
_decoder = _actor->getPage()->loadCel(_fileName);
+ //if (_fileName =="IT01PP01.CEL")
+ // initPallete(_actor->getPage()->getGame()->getDirector());
_actor->getPage()->getGame()->getDirector()->addSprite(this);
this->onStart();
}
diff --git a/engines/pink/objects/actions/action_loop.h b/engines/pink/objects/actions/action_loop.h
index 82b2c1eb94..a031bd1537 100644
--- a/engines/pink/objects/actions/action_loop.h
+++ b/engines/pink/objects/actions/action_loop.h
@@ -36,7 +36,7 @@ protected:
enum Style {
kPingPong = 2,
kRandom = 3,
- kForward // unknown
+ kForward = 4
};
uint _intro;
Style _style;
diff --git a/engines/pink/objects/actions/action_still.cpp b/engines/pink/objects/actions/action_still.cpp
index c49e52ae1d..442fe85330 100644
--- a/engines/pink/objects/actions/action_still.cpp
+++ b/engines/pink/objects/actions/action_still.cpp
@@ -45,7 +45,9 @@ void ActionStill::end() {
void ActionStill::onStart() {
debug("Actor %s has now ActionStill %s", _actor->getName().c_str(), _name.c_str());
- _decoder->seekToFrame(_startFrame);
+ for (int i = 0; i < _startFrame; ++i) {
+ _decoder->decodeNextFrame();
+ }
}
} // End of namespace Pink \ No newline at end of file
diff --git a/engines/pink/objects/actors/lead_actor.cpp b/engines/pink/objects/actors/lead_actor.cpp
index 43e144be1f..55861131d7 100644
--- a/engines/pink/objects/actors/lead_actor.cpp
+++ b/engines/pink/objects/actors/lead_actor.cpp
@@ -33,6 +33,7 @@ namespace Pink {
void LeadActor::deserialize(Archive &archive) {
Actor::deserialize(archive);
+ _state = kReady;
_cursorMgr = static_cast<CursorMgr*>(archive.readObject());
_walkMgr = static_cast<WalkMgr*>(archive.readObject());
_sequencer = static_cast<Sequencer*>(archive.readObject());
diff --git a/engines/pink/objects/module.cpp b/engines/pink/objects/module.cpp
index d1e16f37ee..f768020de0 100644
--- a/engines/pink/objects/module.cpp
+++ b/engines/pink/objects/module.cpp
@@ -81,7 +81,9 @@ PinkEngine *Module::getGame() const {
}
bool Module::checkValueOfVariable(Common::String &variable, Common::String &value) {
- assert(_variables.contains(variable));
+ //assert(_variables.contains(variable));
+ if (!_variables.contains(variable))
+ return value == "UNDEFINED";
return _variables[variable] == value;
}
diff --git a/engines/pink/objects/pages/game_page.cpp b/engines/pink/objects/pages/game_page.cpp
index 5acc1f1858..8711a7ea66 100644
--- a/engines/pink/objects/pages/game_page.cpp
+++ b/engines/pink/objects/pages/game_page.cpp
@@ -56,6 +56,7 @@ void GamePage::init(bool isLoadingSave) {
//assert(perhapsIsLoaded == 0);
loadManagers();
}
+ getGame()->getDirector()->clear();
toConsole();