aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBenjamin Haisch2008-08-26 07:51:31 +0000
committerWillem Jan Palenstijn2011-11-20 22:43:06 +0100
commita94503765df942411d8ec6cf87fb26ead1e904db (patch)
tree63bd9c7a2dd0c1eb1d7a3d41f461a7e620745747 /engines
parent6a83d7d85136158329e3df2a705f09d189ee9e05 (diff)
downloadscummvm-rg350-a94503765df942411d8ec6cf87fb26ead1e904db.tar.gz
scummvm-rg350-a94503765df942411d8ec6cf87fb26ead1e904db.tar.bz2
scummvm-rg350-a94503765df942411d8ec6cf87fb26ead1e904db.zip
TOLTECS: - Fixed setDeltaPalette (sprites at night now look correct)
- Renamed TalkTextItem.rects/rectCount to lines/lineCount - Workaround for font glitch in updateTalkText (text sets invalid font number)
Diffstat (limited to 'engines')
-rw-r--r--engines/toltecs/palette.cpp35
-rw-r--r--engines/toltecs/screen.cpp43
-rw-r--r--engines/toltecs/screen.h4
3 files changed, 36 insertions, 46 deletions
diff --git a/engines/toltecs/palette.cpp b/engines/toltecs/palette.cpp
index 2fb2f8744a..4d0f13f404 100644
--- a/engines/toltecs/palette.cpp
+++ b/engines/toltecs/palette.cpp
@@ -81,31 +81,18 @@ void Palette::setDeltaPalette(byte *palette, byte mask, char deltaValue, int16 c
count++;
- mask &= 7;
-
_vm->_system->grabPalette(colors, 0, 256);
-
- if (deltaValue < 0) {
- deltaValue = -deltaValue;
- while (count--) {
- rgb = *palPtr++;
- if (mask & 1) colors[index * 4 + 0] = CLIP<int>(rgb + deltaValue, 0, 63) << 2;
- rgb = *palPtr++;
- if (mask & 2) colors[index * 4 + 1] = CLIP<int>(rgb + deltaValue, 0, 63) << 2;
- rgb = *palPtr++;
- if (mask & 4) colors[index * 4 + 2] = CLIP<int>(rgb + deltaValue, 0, 63) << 2;
- index++;
- }
- } else {
- while (count--) {
- rgb = *palPtr++;
- if (mask & 1) colors[index * 4 + 0] = CLIP<int>(rgb - deltaValue, deltaValue, 255) << 2;
- rgb = *palPtr++;
- if (mask & 2) colors[index * 4 + 1] = CLIP<int>(rgb - deltaValue, deltaValue, 255) << 2;
- rgb = *palPtr++;
- if (mask & 4) colors[index * 4 + 2] = CLIP<int>(rgb - deltaValue, deltaValue, 255) << 2;
- index++;
- }
+
+ deltaValue *= -1;
+
+ while (count--) {
+ rgb = *palPtr++;
+ if (mask & 1) colors[index * 4 + 0] = CLIP<int>(rgb + deltaValue, 0, 63) << 2;
+ rgb = *palPtr++;
+ if (mask & 2) colors[index * 4 + 1] = CLIP<int>(rgb + deltaValue, 0, 63) << 2;
+ rgb = *palPtr++;
+ if (mask & 4) colors[index * 4 + 2] = CLIP<int>(rgb + deltaValue, 0, 63) << 2;
+ index++;
}
debug(0, "startIndex = %d; colorCount = %d", startIndex, colorCount);
diff --git a/engines/toltecs/screen.cpp b/engines/toltecs/screen.cpp
index c74b4c5dcd..a80c22add1 100644
--- a/engines/toltecs/screen.cpp
+++ b/engines/toltecs/screen.cpp
@@ -708,6 +708,9 @@ void Screen::updateTalkText(int16 slotIndex, int16 slotOffset) {
textData += 2;
} else if (*textData < 0x0A) {
item->fontNum = textData[0];
+ // FIXME: Some texts request a font which isn't registered so we change it to a font that is
+ if (_fontResIndexArray[item->fontNum] == 0)
+ item->fontNum = 0;
textData += 1;
} else
break;
@@ -720,7 +723,7 @@ void Screen::updateTalkText(int16 slotIndex, int16 slotOffset) {
length = 0;
item->duration = 0;
- item->rectCount = 0;
+ item->lineCount = 0;
Font font(_vm->_res->load(_fontResIndexArray[item->fontNum]));
int16 wordLength, wordWidth;
@@ -762,7 +765,7 @@ void Screen::updateTalkText(int16 slotIndex, int16 slotOffset) {
addTalkTextRect(font, x, y, length, width, item);
- debug(0, "## item->rectCount = %d", item->rectCount);
+ debug(0, "## item->lineCount = %d", item->lineCount);
int16 textDurationMultiplier = item->duration + 8;
// TODO: Check sound/text flags
@@ -776,14 +779,14 @@ void Screen::updateTalkText(int16 slotIndex, int16 slotOffset) {
void Screen::addTalkTextRect(Font &font, int16 x, int16 &y, int16 length, int16 width, TalkTextItem *item) {
if (width > 0) {
- TextRect *textRect = &item->rects[item->rectCount];
+ TextRect *textRect = &item->lines[item->lineCount];
width = width + 1 - font.getSpacing();
textRect->width = width;
item->duration += length;
textRect->length = length;
textRect->y = y;
textRect->x = CLIP<int16>(x - width / 2, 0, 640);
- item->rectCount++;
+ item->lineCount++;
}
y += font.getHeight() - 1;
@@ -803,10 +806,10 @@ void Screen::drawTalkTextItems() {
if (item->duration < 0)
item->duration = 0;
- for (byte j = 0; j < item->rectCount; j++) {
- drawString(item->rects[j].x, item->rects[j].y, item->color, _fontResIndexArray[item->fontNum],
- text, item->rects[j].length, NULL, true);
- text += item->rects[j].length;
+ for (byte j = 0; j < item->lineCount; j++) {
+ drawString(item->lines[j].x, item->lines[j].y, item->color, _fontResIndexArray[item->fontNum],
+ text, item->lines[j].length, NULL, true);
+ text += item->lines[j].length;
}
}
@@ -982,12 +985,12 @@ void Screen::saveState(Common::WriteStream *out) {
out->writeUint16LE(_talkTextItems[i].slotOffset);
out->writeUint16LE(_talkTextItems[i].fontNum);
out->writeByte(_talkTextItems[i].color);
- out->writeByte(_talkTextItems[i].rectCount);
- for (int j = 0; j < _talkTextItems[i].rectCount; j++) {
- out->writeUint16LE(_talkTextItems[i].rects[j].x);
- out->writeUint16LE(_talkTextItems[i].rects[j].y);
- out->writeUint16LE(_talkTextItems[i].rects[j].width);
- out->writeUint16LE(_talkTextItems[i].rects[j].length);
+ out->writeByte(_talkTextItems[i].lineCount);
+ for (int j = 0; j < _talkTextItems[i].lineCount; j++) {
+ out->writeUint16LE(_talkTextItems[i].lines[j].x);
+ out->writeUint16LE(_talkTextItems[i].lines[j].y);
+ out->writeUint16LE(_talkTextItems[i].lines[j].width);
+ out->writeUint16LE(_talkTextItems[i].lines[j].length);
}
}
@@ -1033,12 +1036,12 @@ void Screen::loadState(Common::ReadStream *in) {
_talkTextItems[i].slotOffset = in->readUint16LE();
_talkTextItems[i].fontNum = in->readUint16LE();
_talkTextItems[i].color = in->readByte();
- _talkTextItems[i].rectCount = in->readByte();
- for (int j = 0; j < _talkTextItems[i].rectCount; j++) {
- _talkTextItems[i].rects[j].x = in->readUint16LE();
- _talkTextItems[i].rects[j].y = in->readUint16LE();
- _talkTextItems[i].rects[j].width = in->readUint16LE();
- _talkTextItems[i].rects[j].length = in->readUint16LE();
+ _talkTextItems[i].lineCount = in->readByte();
+ for (int j = 0; j < _talkTextItems[i].lineCount; j++) {
+ _talkTextItems[i].lines[j].x = in->readUint16LE();
+ _talkTextItems[i].lines[j].y = in->readUint16LE();
+ _talkTextItems[i].lines[j].width = in->readUint16LE();
+ _talkTextItems[i].lines[j].length = in->readUint16LE();
}
}
diff --git a/engines/toltecs/screen.h b/engines/toltecs/screen.h
index a30c863f33..ec90d52a2c 100644
--- a/engines/toltecs/screen.h
+++ b/engines/toltecs/screen.h
@@ -291,8 +291,8 @@ struct TalkTextItem {
int16 slotOffset;
int16 fontNum;
byte color;
- byte rectCount;
- TextRect rects[15];
+ byte lineCount;
+ TextRect lines[15];
};
class Screen {