DIRECTOR: Reorganize frame palette loading

This commit is contained in:
Nathanael Gentry 2020-07-24 17:40:15 -04:00
parent e1361a4ff9
commit 740cf9f9bf
2 changed files with 36 additions and 51 deletions

View File

@ -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();
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.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();
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);
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();
_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();
if (palette) {
warning("Frame::readChannels(): STUB: Palette info");
}
stream->readByte();
stream->readUint16();
stream->readUint16();
_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);
_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();
stream->readByte();
stream->readUint16();
stream->readUint16();
_palette->colorCode = stream->readByte();
stream->readByte();
} 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
}

View File

@ -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;