[Scummvm-git-logs] scummvm master -> 740cf9f9bf45011cfac3ad96ce8b001bcae0633b
npjg
nathanael.gentrydb8 at gmail.com
Sun Jul 26 21:45:45 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c98cea16b4 DIRECTOR: Keep track of loaded palettes
e1361a4ff9 DIRECTOR: Prettify puppetTransition arg test
740cf9f9bf DIRECTOR: Reorganize frame palette loading
Commit: c98cea16b40460e63e63983772da084f7c654900
https://github.com/scummvm/scummvm/commit/c98cea16b40460e63e63983772da084f7c654900
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-26T17:45:40-04:00
Commit Message:
DIRECTOR: Keep track of loaded palettes
Changed paths:
engines/director/cast.cpp
engines/director/cast.h
engines/director/director.h
engines/director/graphics.cpp
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index 21f73043d3..9dd0901f51 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -95,6 +95,9 @@ Cast::~Cast() {
for (Common::HashMap<int, CastMember *>::iterator it = _loadedCast->begin(); it != _loadedCast->end(); ++it)
delete it->_value;
+ for (uint i = 0; i < _loadedPalettes.size(); i++)
+ delete[] _loadedPalettes[i].palette;
+
delete _loadedStxts;
delete _loadedCast;
delete _lingoArchive;
@@ -192,10 +195,23 @@ void Cast::setArchive(Archive *archive) {
}
bool Cast::loadArchive() {
+ // Palette Information
Common::Array<uint16> clutList = _castArchive->getResourceIDList(MKTAG('C', 'L', 'U', 'T'));
- Common::SeekableSubReadStreamEndian *r = nullptr;
+ if (clutList.size() == 0) {
+ debugC(2, kDebugLoading, "CLUT resource not found, using default Mac palette");
+ } else {
+ for (uint i = 0; i < clutList.size(); i++) {
+ Common::SeekableSubReadStreamEndian *pal = _castArchive->getResource(MKTAG('C', 'L', 'U', 'T'), clutList[i]);
+
+ debugC(2, kDebugLoading, "****** Loading Palette CLUT, #%d", clutList[i]);
+ loadPalette(*pal, i);
+
+ delete pal;
+ }
+ }
// Configuration Information
+ Common::SeekableSubReadStreamEndian *r = nullptr;
if (_castArchive->hasResource(MKTAG('V', 'W', 'C', 'F'), -1)) {
loadConfig(*(r = _castArchive->getFirstResource(MKTAG('V', 'W', 'C', 'F'))));
delete r;
@@ -205,20 +221,6 @@ bool Cast::loadArchive() {
_movie->_stageColor = 1;
}
- if (clutList.size() == 0) {
- warning("CLUT resource not found, using default Mac palette");
- _vm->setPalette(-1);
- } else {
- for (int i = 0; i < clutList.size(); i++) {
- Common::SeekableSubReadStreamEndian *pal = _castArchive->getResource(MKTAG('C', 'L', 'U', 'T'), clutList[i]);
-
- debugC(2, kDebugLoading, "****** Loading Palette CLUT, #%d", clutList[i]);
- loadPalette(*pal);
-
- delete pal;
- }
- }
-
// Font Directory
if (_castArchive->hasResource(MKTAG('F', 'O', 'N', 'D'), -1)) {
debug("Cast::loadArchive(): Movie has fonts. Loading....");
@@ -395,8 +397,18 @@ void Cast::loadConfig(Common::SeekableSubReadStreamEndian &stream) {
stream.readByte();
}
- int palette = (int16)stream.readUint16();
- _vm->setPalette(palette - 1);
+ int palette = (int16)stream.readUint16() - 1;
+ if (palette <= 0) {
+ // Builtin palette
+ _vm->setPalette(palette);
+ } else if ((uint)palette - 1 < _loadedPalettes.size()) {
+ // Loaded palette
+ PaletteV4 pal = _loadedPalettes[palette - 1];
+ _vm->setPalette(pal.palette, pal.length);
+ } else {
+ // Default palette
+ _vm->setPalette(-1);
+ }
for (int i = 0; i < 0x08; i++) {
stream.readByte();
@@ -573,7 +585,7 @@ void Cast::loadSpriteSounds() {
}
}
-void Cast::loadPalette(Common::SeekableSubReadStreamEndian &stream) {
+void Cast::loadPalette(Common::SeekableSubReadStreamEndian &stream, int id) {
uint16 steps = stream.size() / 6;
uint16 index = (steps * 3) - 1;
byte *_palette = new byte[index + 1];
@@ -596,6 +608,8 @@ void Cast::loadPalette(Common::SeekableSubReadStreamEndian &stream) {
stream.readByte();
index -= 3;
}
+
+ _loadedPalettes.push_back(PaletteV4(id, _palette, steps));
}
void Cast::loadCastDataVWCR(Common::SeekableSubReadStreamEndian &stream) {
diff --git a/engines/director/cast.h b/engines/director/cast.h
index 3b599c336c..a4c3db710f 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -77,7 +77,7 @@ public:
void dumpScript(const char *script, ScriptType type, uint16 id);
private:
- void loadPalette(Common::SeekableSubReadStreamEndian &stream);
+ void loadPalette(Common::SeekableSubReadStreamEndian &stream, int id);
void loadScriptText(Common::SeekableSubReadStreamEndian &stream);
void loadFontMap(Common::SeekableSubReadStreamEndian &stream);
Common::String getString(Common::String str);
@@ -88,6 +88,7 @@ public:
Common::HashMap<int, CastMember *> *_loadedCast;
Common::HashMap<int, const Stxt *> *_loadedStxts;
+ Common::Array<PaletteV4> _loadedPalettes;
uint16 _castIDoffset;
uint16 _castArrayStart;
uint16 _castArrayEnd;
diff --git a/engines/director/director.h b/engines/director/director.h
index 92c9bb45e1..159863acf9 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -105,6 +105,8 @@ struct PaletteV4 {
int id;
byte *palette;
int length;
+
+ PaletteV4(int i, byte *p, int l) : id(i), palette(p), length(l) {}
};
struct MacShape {
diff --git a/engines/director/graphics.cpp b/engines/director/graphics.cpp
index d04fae6fd3..7103b5821a 100644
--- a/engines/director/graphics.cpp
+++ b/engines/director/graphics.cpp
@@ -564,15 +564,15 @@ static byte winPalette[768] = {
static PaletteV4 director4Palettes[] = {
- {-1, macPalette, 256},
- {-2, rainbowPalette, 256},
- {-3, grayscalePalette, 256},
- {-4, pastelsPalette, 256},
- {-5, vividPalette, 256},
- {-6, ntscPalette, 256},
- {-7, metallicPalette, 256},
- {-101, winPalette, 256},
- {0, nullptr, 0}
+ PaletteV4(-1, macPalette, 256),
+ PaletteV4(-2, rainbowPalette, 256),
+ PaletteV4(-3, grayscalePalette, 256),
+ PaletteV4(-4, pastelsPalette, 256),
+ PaletteV4(-5, vividPalette, 256),
+ PaletteV4(-6, ntscPalette, 256),
+ PaletteV4(-7, metallicPalette, 256),
+ PaletteV4(-101, winPalette, 256),
+ PaletteV4(0, nullptr, 0)
};
Commit: e1361a4ff9e4d55bb922cc4287071b2c45a90c22
https://github.com/scummvm/scummvm/commit/e1361a4ff9e4d55bb922cc4287071b2c45a90c22
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-26T17:45:40-04:00
Commit Message:
DIRECTOR: Prettify puppetTransition arg test
The if is replaced with a nice switch.
Changed paths:
engines/director/lingo/lingo-builtins.cpp
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index b77a8f4bd6..6ef172b7b1 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1783,25 +1783,24 @@ void LB::b_puppetTransition(int nargs) {
// puppetTransition whichTransition [, time] [, chunkSize] [, changeArea]
Stage *stage = g_director->getCurrentStage();
uint16 duration = 250, area = 1, chunkSize = 1, type = 0;
- if (nargs == 4) {
- area = g_lingo->pop().asInt();
- nargs--;
- }
- if (nargs == 3) {
+ switch (nargs) {
+ case 4:
+ area = g_lingo->pop().asInt();
+ // fall through
+ case 3:
chunkSize = g_lingo->pop().asInt();
- nargs--;
- }
-
- if (nargs == 2) {
- duration = g_lingo->pop().asInt();
- nargs--;
- }
-
- if (nargs == 1) {
+ // fall through
+ case 2:
+ duration = g_lingo->pop().asInt();
+ // fall through
+ case 1:
type = ((TransitionType)(g_lingo->pop().asInt()));
- } else {
+ break;
+ default:
ARGNUMCHECK(1);
+ g_lingo->dropStack(nargs);
+ return;
}
if (stage->_puppetTransition) {
Commit: 740cf9f9bf45011cfac3ad96ce8b001bcae0633b
https://github.com/scummvm/scummvm/commit/740cf9f9bf45011cfac3ad96ce8b001bcae0633b
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-07-26T17:45:40-04:00
Commit Message:
DIRECTOR: Reorganize frame palette loading
Changed paths:
engines/director/frame.cpp
engines/director/frame.h
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index ae9f815da3..35fd5ba245 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -51,8 +51,6 @@ Frame::Frame(Score *score, int numChannels) {
_skipFrameFlag = 0;
_blend = 0;
- _palette = NULL;
-
_colorTempo = 0;
_colorSound1 = 0;
_colorSound2 = 0;
@@ -89,7 +87,7 @@ Frame::Frame(const Frame &frame) {
_colorScript = frame._colorScript;
_colorTrans = frame._colorTrans;
- _palette = new PaletteInfo();
+ _palette = frame._palette;
debugC(1, kDebugLoading, "Frame. action: %d transType: %d transDuration: %d", _actionId, _transType, _transDuration);
@@ -101,8 +99,6 @@ Frame::Frame(const Frame &frame) {
}
Frame::~Frame() {
- delete _palette;
-
for (uint16 i = 0; i < _sprites.size(); i++)
delete _sprites[i];
}
@@ -165,25 +161,18 @@ void Frame::readChannels(Common::ReadStreamEndian *stream) {
}
// palette
- uint16 palette = stream->readUint16();
+ _palette.paletteId = stream->readUint16();
+ _palette.firstColor = stream->readByte(); // for cycles. note: these start at 0x80 (for pal entry 0)!
+ _palette.lastColor = stream->readByte();
+ _palette.flags = stream->readByte();
+ _palette.speed = stream->readByte();
+ _palette.frameCount = stream->readUint16();
+ _palette.cycleCount = stream->readUint16();
- if (palette) {
- warning("Frame::readChannels(): STUB: Palette info");
- }
+ stream->read(unk, 6);
debugC(8, kDebugLoading, "Frame::readChannels(): %d %d %d %d %d %d %d %d %d %d %d", _actionId, _soundType1, _transDuration, _transChunkSize, _tempo, _transType, _sound1, _skipFrameFlag, _blend, _sound2, _soundType2);
- _palette = new PaletteInfo();
- _palette->firstColor = stream->readByte(); // for cycles. note: these start at 0x80 (for pal entry 0)!
- _palette->lastColor = stream->readByte();
- _palette->flags = stream->readByte();
- _palette->speed = stream->readByte();
- _palette->frameCount = stream->readUint16();
-
- _palette->cycleCount = stream->readUint16();
-
- stream->read(unk, 6);
-
if (_vm->getPlatform() == Common::kPlatformMacintosh)
stream->read(unk, 3);
} else if (_vm->getVersion() == 4) {
@@ -222,32 +211,26 @@ void Frame::readChannels(Common::ReadStreamEndian *stream) {
_colorTrans = stream->readByte();
// palette
- uint16 palette = stream->readUint16();
-
- if (palette) {
- warning("Frame::readChannels(): STUB: Palette info");
- }
-
- debugC(8, kDebugLoading, "Frame::readChannels(): %d %d %d %d %d %d %d %d %d %d %d", _actionId, _soundType1, _transDuration, _transChunkSize, _tempo, _transType, _sound1, _skipFrameFlag, _blend, _sound2, _soundType2);
-
- _palette = new PaletteInfo();
- _palette->firstColor = stream->readByte(); // for cycles. note: these start at 0x80 (for pal entry 0)!
- _palette->lastColor = stream->readByte();
- _palette->flags = stream->readByte();
- _palette->speed = stream->readByte();
- _palette->frameCount = stream->readUint16();
-
- _palette->cycleCount = stream->readUint16();
- _palette->fade = stream->readByte();
- _palette->delay = stream->readByte();
- _palette->style = stream->readByte();
+ _palette.paletteId = stream->readUint16();
+ _palette.firstColor = stream->readByte(); // for cycles. note: these start at 0x80 (for pal entry 0)!
+ _palette.lastColor = stream->readByte();
+ _palette.flags = stream->readByte();
+ _palette.speed = stream->readByte();
+ _palette.frameCount = stream->readUint16();
+ _palette.cycleCount = stream->readUint16();
+ _palette.fade = stream->readByte();
+ _palette.delay = stream->readByte();
+ _palette.style = stream->readByte();
stream->readByte();
stream->readUint16();
stream->readUint16();
- _palette->colorCode = stream->readByte();
+ _palette.colorCode = stream->readByte();
+
stream->readByte();
+
+ debugC(8, kDebugLoading, "Frame::readChannels(): %d %d %d %d %d %d %d %d %d %d %d", _actionId, _soundType1, _transDuration, _transChunkSize, _tempo, _transType, _sound1, _skipFrameFlag, _blend, _sound2, _soundType2);
} else if (_vm->getVersion() == 5) {
// Sound/Tempo/Transition channel
stream->read(unk, 24);
@@ -453,11 +436,11 @@ void Frame::readMainChannels(Common::SeekableSubReadStreamEndian &stream, uint16
}
void Frame::readPaletteInfo(Common::SeekableSubReadStreamEndian &stream) {
- _palette->firstColor = stream.readByte();
- _palette->lastColor = stream.readByte();
- _palette->flags = stream.readByte();
- _palette->speed = stream.readByte();
- _palette->frameCount = stream.readUint16();
+ _palette.firstColor = stream.readByte();
+ _palette.lastColor = stream.readByte();
+ _palette.flags = stream.readByte();
+ _palette.speed = stream.readByte();
+ _palette.frameCount = stream.readUint16();
stream.skip(8); // unknown
}
diff --git a/engines/director/frame.h b/engines/director/frame.h
index b77bb5e387..ca1cd24f49 100644
--- a/engines/director/frame.h
+++ b/engines/director/frame.h
@@ -47,6 +47,8 @@ enum {
};
struct PaletteInfo {
+ uint16 paletteId;
+
byte firstColor;
byte lastColor;
byte flags;
@@ -86,7 +88,7 @@ private:
Image::ImageDecoder *getImageFrom(uint16 spriteId);
Common::String readTextStream(Common::SeekableSubReadStreamEndian *textStream, TextCastMember *textCast);
-
+
public:
int _numChannels;
byte _channelData[kChannelDataSize];
@@ -95,7 +97,7 @@ public:
uint8 _transArea; // 1 - Whole Stage, 0 - Changing Area
uint8 _transChunkSize;
TransitionType _transType;
- PaletteInfo *_palette;
+ PaletteInfo _palette;
uint8 _tempo;
uint16 _sound1;
More information about the Scummvm-git-logs
mailing list