aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Iskrich2016-06-17 15:08:05 +0300
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commit6b5c0626f7318542726bacce75a56b93af59fbe5 (patch)
treeb1560355dc521a34276cfc50c73966447e4c309e
parent57e092ab8f4212b5fa3e549dcf45e8bd2f3237d9 (diff)
downloadscummvm-rg350-6b5c0626f7318542726bacce75a56b93af59fbe5.tar.gz
scummvm-rg350-6b5c0626f7318542726bacce75a56b93af59fbe5.tar.bz2
scummvm-rg350-6b5c0626f7318542726bacce75a56b93af59fbe5.zip
DIRECTOR: Load palette directly to engine
-rw-r--r--engines/director/director.cpp10
-rw-r--r--engines/director/director.h9
-rw-r--r--engines/director/score.cpp35
-rw-r--r--engines/director/score.h5
4 files changed, 47 insertions, 12 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 7808d52040..dfb4928b2b 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -64,6 +64,7 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
DirectorEngine::~DirectorEngine() {
delete _mainArchive;
delete _macBinary;
+ delete[] _currentPalette;
}
Common::Error DirectorEngine::run() {
@@ -85,7 +86,7 @@ Common::Error DirectorEngine::run() {
_mainArchive = new RIFFArchive();
_mainArchive->openFile("bookshelf_example.mmm");
- Score score(*_mainArchive, *_lingo, *_soundManager);
+ Score score(this);
debug(0, "Score name %s", score.getMacName().c_str());
score.loadArchive();
@@ -110,7 +111,7 @@ Common::HashMap<Common::String, Score *> DirectorEngine::loadMMMNames(Common::St
for (Common::FSList::const_iterator i = movies.begin(); i != movies.end(); ++i) {
RIFFArchive *arc = new RIFFArchive();
arc->openFile(i->getPath());
- Score *sc = new Score(*arc, *_lingo, *_soundManager);
+ Score *sc = new Score(this);
nameMap[sc->getMacName()] = sc;
}
}
@@ -266,4 +267,9 @@ Common::String DirectorEngine::readPascalString(Common::SeekableReadStream &stre
return x;
}
+void DirectorEngine::setPalette(byte *palette, uint16 count) {
+ _currentPalette = palette;
+ _currentPaletteLength = count;
+}
+
} // End of namespace Director
diff --git a/engines/director/director.h b/engines/director/director.h
index 9a961b78e7..7e32d5f8ca 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -59,7 +59,12 @@ public:
Common::Language getLanguage() const;
Common::String getEXEName() const;
DirectorSound *getSoundManager() const { return _soundManager; }
+ Archive *getMainArchive() const { return _mainArchive; }
+ Lingo *getLingo() const { return _lingo; }
+ void setPalette(byte *palette, uint16 count);
bool hasFeature(EngineFeature f) const;
+ const byte *getPalette() const { return _currentPalette; }
+ uint16 getPaletteColorCount() const { return _currentPaletteLength; }
protected:
virtual Common::Error run();
@@ -74,7 +79,6 @@ private:
void loadEXEv5(Common::SeekableReadStream *stream);
void loadEXEv7(Common::SeekableReadStream *stream);
void loadEXERIFX(Common::SeekableReadStream *stream, uint32 offset);
-
void loadMac();
Common::String readPascalString(Common::SeekableReadStream &stream);
@@ -82,7 +86,8 @@ private:
Archive *_mainArchive;
Common::MacResManager *_macBinary;
DirectorSound *_soundManager;
-
+ byte *_currentPalette;
+ uint16 _currentPaletteLength;
Lingo *_lingo;
};
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 7868353dd5..8a40670cf7 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -39,12 +39,13 @@
namespace Director {
-Score::Score(Archive &movie, Lingo &lingo, DirectorSound &soundManager) {
+Score::Score(DirectorEngine *vm) {
+ _vm = vm;
_surface = new Graphics::ManagedSurface;
_trailSurface = new Graphics::ManagedSurface;
- _movieArchive = &movie;
- _lingo = &lingo;
- _soundManager = &soundManager;
+ _movieArchive = _vm->getMainArchive();
+ _lingo = _vm->getLingo();
+ _soundManager = _vm->getSoundManager();
_lingo->processEvent(kEventPrepareMovie, 0);
_movieScriptCount = 0;
@@ -95,7 +96,7 @@ void Score::loadArchive() {
}
}
- DIBDecoder palette;
+
Common::Array<uint16> clutList = _movieArchive->getResourceIDList(MKTAG('C','L','U','T'));
if (clutList.size() > 1)
@@ -106,8 +107,8 @@ void Score::loadArchive() {
Common::SeekableReadStream *pal = _movieArchive->getResource(MKTAG('C', 'L', 'U', 'T'), clutList[0]);
- palette.loadPalette(*pal);
- g_system->getPaletteManager()->setPalette(palette.getPalette(), 0, palette.getPaletteColorCount());
+ loadPalette(*pal);
+ g_system->getPaletteManager()->setPalette(_vm->getPalette(), 0, _vm->getPaletteColorCount());
}
Score::~Score() {
@@ -121,6 +122,26 @@ Score::~Score() {
delete _movieArchive;
}
+void Score::loadPalette(Common::SeekableReadStream &stream) {
+ uint16 steps = stream.size() / 6;
+ uint16 index = (steps * 3) - 1;
+ uint16 _paletteColorCount = steps;
+ byte *_palette = new byte[index];
+
+ for (uint8 i = 0; i < steps; i++) {
+ _palette[index - 2] = stream.readByte();
+ stream.readByte();
+
+ _palette[index - 1] = stream.readByte();
+ stream.readByte();
+
+ _palette[index] = stream.readByte();
+ stream.readByte();
+ index -= 3;
+ }
+ _vm->setPalette(_palette, _paletteColorCount);
+}
+
void Score::loadFrames(Common::SeekableReadStream &stream) {
uint32 size = stream.readUint32BE();
size -= 4;
diff --git a/engines/director/score.h b/engines/director/score.h
index 9490d5f54d..9ac8685090 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -35,6 +35,7 @@ namespace Director {
class Lingo;
class DirectorSound;
class Score;
+class DirectorEngine;
#define CHANNEL_COUNT 24
@@ -285,7 +286,7 @@ public:
class Score {
public:
- Score(Archive &movie, Lingo &lingo, DirectorSound &soundManager);
+ Score(DirectorEngine *vm);
~Score();
static Common::Rect readRect(Common::SeekableReadStream &stream);
@@ -298,6 +299,7 @@ private:
void update();
void readVersion(uint32 rid);
void loadConfig(Common::SeekableReadStream &stream);
+ void loadPalette(Common::SeekableReadStream &stream);
void loadCastData(Common::SeekableReadStream &stream);
void loadFrames(Common::SeekableReadStream &stream);
void loadLabels(Common::SeekableReadStream &stream);
@@ -341,6 +343,7 @@ private:
uint16 _stageColor;
Lingo *_lingo;
DirectorSound *_soundManager;
+ DirectorEngine *_vm;
};
} //End of namespace Director