aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLe Philousophe2019-05-20 20:49:01 +0200
committerEugene Sandulenko2019-06-01 22:43:48 +0200
commit1c4d0d87ecde1fdea1cf1473da3665605d956657 (patch)
tree086c86a60234886c0f40f2e6d45cd81857243ebb
parentcba0ee7296aa3543e90329fd1928e5f9cea8a2dd (diff)
downloadscummvm-rg350-1c4d0d87ecde1fdea1cf1473da3665605d956657.tar.gz
scummvm-rg350-1c4d0d87ecde1fdea1cf1473da3665605d956657.tar.bz2
scummvm-rg350-1c4d0d87ecde1fdea1cf1473da3665605d956657.zip
CRYOMNI3D: Use existing palette to init video one
This is useful when there will be hooks on video plays which use a palette entry not defined in video
-rw-r--r--engines/cryomni3d/cryomni3d.cpp6
-rw-r--r--engines/cryomni3d/video/hnm_decoder.cpp18
-rw-r--r--engines/cryomni3d/video/hnm_decoder.h5
3 files changed, 21 insertions, 8 deletions
diff --git a/engines/cryomni3d/cryomni3d.cpp b/engines/cryomni3d/cryomni3d.cpp
index ae05778681..473fc7cce6 100644
--- a/engines/cryomni3d/cryomni3d.cpp
+++ b/engines/cryomni3d/cryomni3d.cpp
@@ -118,7 +118,11 @@ void CryOmni3DEngine::playHNM(const Common::String &filename, Audio::Mixer::Soun
const char *const extensions[] = { "hns", "hnm", nullptr };
Common::String fname(prepareFileName(filename, extensions));
- Video::VideoDecoder *videoDecoder = new Video::HNMDecoder();
+ byte *currentPalette = new byte[256 * 3];
+ g_system->getPaletteManager()->grabPalette(currentPalette, 0, 256);
+
+ // Pass the ownership of currentPalette to HNMDecoder
+ Video::VideoDecoder *videoDecoder = new Video::HNMDecoder(false, currentPalette);
videoDecoder->setSoundType(soundType);
if (!videoDecoder->loadFile(fname)) {
diff --git a/engines/cryomni3d/video/hnm_decoder.cpp b/engines/cryomni3d/video/hnm_decoder.cpp
index 355345beaa..0451828f0c 100644
--- a/engines/cryomni3d/video/hnm_decoder.cpp
+++ b/engines/cryomni3d/video/hnm_decoder.cpp
@@ -35,13 +35,16 @@
namespace Video {
// When no sound display a frame every 80ms
-HNMDecoder::HNMDecoder(bool loop) : _regularFrameDelay(80), _videoTrack(nullptr),
- _audioTrack(nullptr), _stream(nullptr), _loop(loop) {
+HNMDecoder::HNMDecoder(bool loop, byte *initialPalette) : _regularFrameDelay(80),
+ _videoTrack(nullptr), _audioTrack(nullptr), _stream(nullptr),
+ _loop(loop), _initialPalette(initialPalette) {
}
HNMDecoder::~HNMDecoder() {
close();
+ delete[] _initialPalette;
+
// We don't deallocate _videoTrack and _audioTrack as they are owned by base class
}
@@ -79,7 +82,7 @@ bool HNMDecoder::loadStream(Common::SeekableReadStream *stream) {
frameCount = 0;
}
- _videoTrack = new HNM4VideoTrack(width, height, frameSize, frameCount, _regularFrameDelay);
+ _videoTrack = new HNM4VideoTrack(width, height, frameSize, frameCount, _regularFrameDelay, _initialPalette);
if (soundBits != 0 && soundChannels != 0) {
// HNM4 is 22050Hz
_audioTrack = new DPCMAudioTrack(soundChannels, soundBits, 22050, getSoundType());
@@ -149,13 +152,18 @@ void HNMDecoder::readNextPacket() {
}
HNMDecoder::HNM4VideoTrack::HNM4VideoTrack(uint32 width, uint32 height, uint32 frameSize,
- uint32 frameCount, uint32 regularFrameDelay) :
+ uint32 frameCount, uint32 regularFrameDelay, const byte *initialPalette) :
_frameCount(frameCount), _regularFrameDelay(regularFrameDelay), _nextFrameStartTime(0) {
restart();
_curFrame = -1;
- memset(_palette, 0, 256 * 3);
+ // Get the currently loaded palette for undefined colors
+ if (initialPalette) {
+ memcpy(_palette, initialPalette, 256 * 3);
+ } else {
+ memset(_palette, 0, 256 * 3);
+ }
if (width * height != frameSize) {
error("Invalid frameSize");
diff --git a/engines/cryomni3d/video/hnm_decoder.h b/engines/cryomni3d/video/hnm_decoder.h
index b09026b674..c5d9307bb7 100644
--- a/engines/cryomni3d/video/hnm_decoder.h
+++ b/engines/cryomni3d/video/hnm_decoder.h
@@ -43,7 +43,7 @@ namespace Video {
*/
class HNMDecoder : public VideoDecoder {
public:
- HNMDecoder(bool loop = false);
+ HNMDecoder(bool loop = false, byte *initialPalette = nullptr);
virtual ~HNMDecoder();
bool loadStream(Common::SeekableReadStream *stream);
void readNextPacket();
@@ -55,7 +55,7 @@ private:
class HNM4VideoTrack : public VideoTrack {
public:
HNM4VideoTrack(uint32 width, uint32 height, uint32 frameSize, uint32 frameCount,
- uint32 regularFrameDelay);
+ uint32 regularFrameDelay, const byte *initialPalette = nullptr);
~HNM4VideoTrack();
// When _frameCount is 0, it means we are looping
@@ -113,6 +113,7 @@ private:
};
bool _loop;
+ byte *_initialPalette;
uint32 _regularFrameDelay;
// These two pointer are owned by VideoDecoder