Skip to content
Permalink
Browse files

DIRECTOR: Normalize reading of thickness and ink data reading from score

  • Loading branch information
sev- committed Mar 24, 2020
1 parent 05b3a64 commit d6461cdc8b61e9cb4a1c46ac46b8b32160c8be91
Showing with 29 additions and 32 deletions.
  1. +20 −23 engines/director/frame.cpp
  2. +2 −2 engines/director/lingo/lingo-the.cpp
  3. +4 −4 engines/director/sprite.cpp
  4. +3 −3 engines/director/sprite.h
@@ -223,15 +223,8 @@ void Frame::readChannels(Common::ReadStreamEndian *stream) {
sprite._backColor = _vm->transformColor((128 + stream->readByte()) & 0xff);
}

sprite._flags = stream->readUint16();
sprite._ink = static_cast<InkType>(sprite._flags & 0x3f);

if (sprite._flags & 0x40)
sprite._trails = 1;
else
sprite._trails = 0;

sprite._lineSize = ((sprite._flags >> 8) & 0x07);
sprite._thickness = stream->readByte();
sprite._inkData = stream->readByte();

sprite._castId = stream->readUint16();
sprite._startPoint.y = stream->readUint16();
@@ -255,12 +248,7 @@ void Frame::readChannels(Common::ReadStreamEndian *stream) {
}
} else {
sprite._spriteType = stream->readByte();
sprite._flags = stream->readByte();
sprite._ink = static_cast<InkType>(sprite._flags & 0x3f);
if (sprite._flags & 0x40)
sprite._trails = 1;
else
sprite._trails = 0;
sprite._inkData = stream->readByte();

sprite._castIndex = stream->readUint16();
sprite._castId = stream->readUint16();
@@ -277,14 +265,22 @@ void Frame::readChannels(Common::ReadStreamEndian *stream) {
sprite._colorcode = stream->readByte();
sprite._blendAmount = stream->readByte();
sprite._moveable = ((sprite._colorcode & 0x80) == 0x80);
sprite._lineSize = stream->readByte();
sprite._thickness = stream->readByte();
stream->readByte(); // unused
}

sprite._ink = static_cast<InkType>(sprite._inkData & 0x3f);

if (sprite._inkData & 0x40)
sprite._trails = 1;
else
sprite._trails = 0;


if (sprite._castId) {
debugC(4, kDebugLoading, "CH: %-3d castId: %03d(%s) [flags:%04x [ink: %x trails: %d line: %d], %dx%d@%d,%d type: %d fg: %d bg: %d] script: %d, flags2: %x, unk2: %x, unk3: %x",
i + 1, sprite._castId, numToCastNum(sprite._castId), sprite._flags,
sprite._ink, sprite._trails, sprite._lineSize, sprite._width, sprite._height,
i + 1, sprite._castId, numToCastNum(sprite._castId), sprite._inkData,
sprite._ink, sprite._trails, sprite._thickness, sprite._width, sprite._height,
sprite._startPoint.x, sprite._startPoint.y,
sprite._spriteType, sprite._foreColor, sprite._backColor, sprite._scriptId, sprite._colorcode, sprite._blendAmount, sprite._unk3);
} else {
@@ -399,10 +395,11 @@ void Frame::readSprite(Common::SeekableSubReadStreamEndian &stream, uint16 offse
fieldPosition += 2;
break;
case kSpritePositionFlags:
sprite._flags = stream.readUint16();
sprite._ink = static_cast<InkType>(sprite._flags & 0x3f);
sprite._thickness = stream.readByte();
sprite._inkData = stream.readByte();
sprite._ink = static_cast<InkType>(sprite._inkData & 0x3f);

if (sprite._flags & 0x40)
if (sprite._inkData & 0x40)
sprite._trails = 1;
else
sprite._trails = 0;
@@ -436,7 +433,7 @@ void Frame::readSprite(Common::SeekableSubReadStreamEndian &stream, uint16 offse
break;
}
}
warning("Frame::readSprite(): %03d(%d)[%x,%x,%04x,%d/%d/%d/%d]", sprite._castId, sprite._enabled, x1, x2, sprite._flags, sprite._startPoint.x, sprite._startPoint.y, sprite._width, sprite._height);
warning("Frame::readSprite(): %03d(%d)[%x,%x,%02x %02x,%d/%d/%d/%d]", sprite._castId, sprite._enabled, x1, x2, sprite._thickness, sprite._inkData, sprite._startPoint.x, sprite._startPoint.y, sprite._width, sprite._height);

}

@@ -571,7 +568,7 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteId) {
byte spriteType = sp->_spriteType;
byte foreColor = sp->_foreColor;
byte backColor = sp->_backColor;
int lineSize = sp->_lineSize;
int lineSize = sp->_thickness & 0x3;
if (spriteType == kCastMemberSprite && sp->_cast != NULL) {
switch (sp->_cast->_type) {
case kCastShape:
@@ -523,7 +523,7 @@ Datum Lingo::getTheSprite(Datum &id1, int field) {
d.u.i = sprite->_left;
break;
case kTheLineSize:
d.u.i = sprite->_lineSize;
d.u.i = sprite->_thickness & 0x3;
break;
case kTheLocH:
d.u.i = sprite->_startPoint.x;
@@ -640,7 +640,7 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
sprite->_left = d.u.i;
break;
case kTheLineSize:
sprite->_lineSize = d.u.i;
sprite->_thickness = d.u.i;
break;
case kTheLocH:
sprite->_startPoint.x = d.u.i;
@@ -31,7 +31,7 @@ Sprite::Sprite() {
_trails = 0;
_width = 0;
_ink = kInkTypeCopy;
_flags = 0;
_inkData = 0;
_height = 0;
_castId = 0;
_constraint = 0;
@@ -56,7 +56,7 @@ Sprite::Sprite() {
_cast = nullptr;

_blend = 0;
_lineSize = 1;
_thickness = 0;

_scriptId = 0;
_scriptCastIndex = 0;
@@ -70,9 +70,9 @@ Sprite::Sprite(const Sprite &sprite) {
_enabled = sprite._enabled;
_castId = sprite._castId;
_castIndex = sprite._castIndex;
_flags = sprite._flags;
_trails = sprite._trails;
_ink = sprite._ink;
_inkData = sprite._inkData;
_width = sprite._width;
_height = sprite._height;
_startPoint.x = sprite._startPoint.x;
@@ -97,7 +97,7 @@ Sprite::Sprite(const Sprite &sprite) {
_moveable = sprite._moveable;
_blend = sprite._blend;
_startTime = sprite._startTime;
_lineSize = sprite._lineSize;
_thickness = sprite._thickness;

_scriptId = sprite._scriptId;
_scriptCastIndex = sprite._scriptCastIndex;
@@ -76,12 +76,13 @@ class Sprite {
uint16 _castId;
uint16 _castIndex;
byte _spriteType;
byte _inkData;
InkType _ink;
uint16 _trails;

Cast *_cast;

uint16 _flags;
byte _thickness;
Common::Point _startPoint;
uint16 _width;
uint16 _height;
@@ -106,8 +107,7 @@ class Sprite {
uint16 _stopTime;
byte _volume;
byte _stretch;
// Using in shape sprites
byte _lineSize;

// Using in text sprites
Common::String _editableText;
};

0 comments on commit d6461cd

Please sign in to comment.
You can’t perform that action at this time.