aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/kyra/lol.cpp19
-rw-r--r--engines/kyra/lol.h6
-rw-r--r--engines/kyra/screen.cpp26
-rw-r--r--engines/kyra/screen.h3
-rw-r--r--engines/kyra/screen_lol.cpp7
-rw-r--r--engines/kyra/screen_lol.h2
-rw-r--r--engines/kyra/script_lol.cpp3
-rw-r--r--engines/kyra/script_tim.cpp10
-rw-r--r--engines/kyra/sprites_lol.cpp71
-rw-r--r--engines/kyra/text_lol.cpp133
-rw-r--r--engines/kyra/text_lol.h19
11 files changed, 157 insertions, 142 deletions
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp
index e17275545d..09e3ca14c9 100644
--- a/engines/kyra/lol.cpp
+++ b/engines/kyra/lol.cpp
@@ -719,8 +719,6 @@ void LoLEngine::startup() {
_txt->setAnimParameters("<MORE>", 10, 31, 0);
_txt->setAnimFlag(true);
- _screen->_dimLineCount = 0;
-
_sound->loadSfxFile("LORESFX");
setMouseCursorToItemInHand();
@@ -1016,7 +1014,7 @@ void LoLEngine::initTextFading(int textType, int clearField) {
updatePortraits();
if (_hideInventory)
- _screen->clearDim(3);
+ _screen->setScreenDim(_txt->clearDim(3));
_fadeText = false;
_timer->disable(11);
@@ -1235,7 +1233,7 @@ void LoLEngine::initNonAnimatedDialogue(int controlMode, int pageNum) {
_screen->modifyScreenDim(5, 8, 131, 304, 66);
_screen->modifyScreenDim(4, 1, 133, 38, 60);
- _screen->clearDim(4);
+ _txt->clearDim(4);
_updateFlags |= 2;
_hideControls = controlMode;
@@ -1257,7 +1255,7 @@ void LoLEngine::initNonAnimatedDialogue(int controlMode, int pageNum) {
_txt->setupField(true);
_txt->expandField();
setupScreenDims();
- _screen->clearDim(4);
+ _txt->clearDim(4);
}
_hideControls = controlMode;
@@ -1279,8 +1277,7 @@ void LoLEngine::restoreAfterNonAnimatedDialogue(int controlMode) {
} else {
const ScreenDim *d = _screen->getScreenDim(5);
_screen->fillRect(d->sx, d->sy, d->sx + d->w - 2, d->sy + d->h - 2, d->unkA);
- _screen->clearDim(4);
- _screen->setScreenDim(4);
+ _txt->clearDim(4);
_txt->setupField(false);
}
@@ -1305,7 +1302,7 @@ void LoLEngine::fadeText() {
if (_hideInventory)
return;
- _screen->clearDim(3);
+ _screen->setScreenDim(_txt->clearDim(3));
_timer->disable(11);
@@ -1690,15 +1687,13 @@ int LoLEngine::playCharacterScriptChat(int charId, int mode, int unk1, char *str
_txt->printDialogueText(3, str, script, paramList, paramIndex);
} else if (mode == 1) {
- _screen->setScreenDim(4);
- _screen->clearDim(4);
+ _txt->clearDim(4);
_screen->modifyScreenDim(4, 16, 123, 23, 47);
_txt->printDialogueText(4, str, script, paramList, paramIndex);
_screen->modifyScreenDim(4, 11, 123, 28, 47);
} else if (mode == 2) {
- _screen->setScreenDim(4);
- _screen->clearDim(4);
+ _txt->clearDim(4);
_screen->modifyScreenDim(4, 9, 133, 30, 60);
_txt->printDialogueText(4, str, script, paramList, 3);
_screen->modifyScreenDim(4, 1, 133, 37, 60);
diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h
index 51db2e04e4..acd385dfb8 100644
--- a/engines/kyra/lol.h
+++ b/engines/kyra/lol.h
@@ -1031,9 +1031,9 @@ private:
void removeDrawObjectFromBlock(LevelBlockProperty *l, int id);
void assignMonsterToBlock(uint16 *assignedBlockObjects, int id);
void giveItemToMonster(MonsterInPlay *monster, uint16 item);
- int checkBlockBeforeObjectPlacement(int x, int y, int monsterWidth, int testFlag, int wallFlag);
- int calcMonsterSkillLevel(int id, int a);
- int checkBlockForWallsAndSufficientSpace(int block, int x, int y, int monsterWidth, int testFlag, int wallFlag);
+ int checkBlockBeforeObjectPlacement(int x, int y, int objectWidth, int testFlag, int wallFlag);
+ int checkBlockForWallsAndSufficientSpace(int block, int x, int y, int objectWidth, int testFlag, int wallFlag);
+ int calcMonsterSkillLevel(int id, int a);
bool checkBlockOccupiedByParty(int x, int y, int testFlag);
const uint16 *getCharacterOrMonsterStats(int id);
void drawBlockObjects(int blockArrayIndex);
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index 04227322ed..ec0a899dcc 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -1151,12 +1151,11 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int
_dsTable = 0;
_dsTableLoopCount = 0;
_dsTable2 = 0;
+ _dsTable3 = 0;
+ _dsTable4 = 0;
_dsTable5 = 0;
_dsDrawLayer = 0;
- uint8 *table3 = 0;
- uint8 *table4 = 0;
-
if (flags & 0x8000) {
_dsTable2 = va_arg(args, uint8*);
}
@@ -1169,8 +1168,8 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int
}
if (flags & 0x1000) {
- table3 = va_arg(args, uint8*);
- table4 = va_arg(args, uint8*);
+ _dsTable3 = va_arg(args, uint8*);
+ _dsTable4 = va_arg(args, uint8*);
}
if (flags & 0x200) {
@@ -1252,8 +1251,11 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
&Screen::drawShapePlotType37, // used by LoL (monsters)
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ &Screen::drawShapePlotType52,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0
};
int scaleCounterV = 0;
@@ -1827,6 +1829,16 @@ void Screen::drawShapePlotType37(uint8 *dst, uint8 cmd) {
*dst = cmd;
}
+void Screen::drawShapePlotType52(uint8 *dst, uint8 cmd) {
+ cmd = _dsTable2[cmd];
+ uint8 offs = _dsTable3[cmd];
+
+ if (!(offs & 0x80))
+ cmd = _dsTable4[(offs << 8) | *dst];
+
+ *dst = cmd;
+}
+
void Screen::decodeFrame3(const uint8 *src, uint8 *dst, uint32 size) {
debugC(9, kDebugLevelScreen, "Screen::decodeFrame3(%p, %p, %u)", (const void *)src, (const void *)dst, size);
const uint8 *dstEnd = dst + size;
diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h
index 737cd03082..8fa098e2eb 100644
--- a/engines/kyra/screen.h
+++ b/engines/kyra/screen.h
@@ -333,6 +333,7 @@ protected:
void drawShapePlotType13(uint8 *dst, uint8 cmd);
void drawShapePlotType14(uint8 *dst, uint8 cmd);
void drawShapePlotType37(uint8 *dst, uint8 cmd);
+ void drawShapePlotType52(uint8 *dst, uint8 cmd);
typedef int (Screen::*DsMarginSkipFunc)(uint8 *&dst, const uint8 *&src, int &cnt);
typedef void (Screen::*DsLineFunc)(uint8 *&dst, const uint8 *&src, int &cnt, int scaleState);
@@ -346,6 +347,8 @@ protected:
const uint8 *_dsTable;
int _dsTableLoopCount;
const uint8 *_dsTable2;
+ const uint8 *_dsTable3;
+ const uint8 *_dsTable4;
const uint8 *_dsTable5;
int _dsDrawLayer;
uint8 *_dsDstPage;
diff --git a/engines/kyra/screen_lol.cpp b/engines/kyra/screen_lol.cpp
index 884dee4712..16f1c96ec1 100644
--- a/engines/kyra/screen_lol.cpp
+++ b/engines/kyra/screen_lol.cpp
@@ -46,7 +46,6 @@ Screen_LoL::Screen_LoL(LoLEngine *vm, OSystem *system) : Screen_v2(vm, system),
_fadeFlag = 2;
_curDimIndex = 0;
- _dimLineCount = 0;
}
Screen_LoL::~Screen_LoL() {
@@ -67,7 +66,6 @@ void Screen_LoL::setScreenDim(int dim) {
assert(dim < _screenDimTableCount);
_curDim = _customDimTable[dim] ? (const ScreenDim *)_customDimTable[dim] : &_screenDimTable[dim];
_curDimIndex = dim;
- _dimLineCount = 0;
}
const ScreenDim *Screen_LoL::getScreenDim(int dim) {
@@ -87,11 +85,6 @@ void Screen_LoL::modifyScreenDim(int dim, int x, int y, int w, int h) {
setScreenDim(dim);
}
-void Screen_LoL::clearDim(int dim) {
- const ScreenDim *tmp = getScreenDim(dim);
- fillRect(tmp->sx << 3, tmp->sy, ((tmp->sx + tmp->w) << 3) - 1, (tmp->sy + tmp->h) - 1, tmp->unkA);
-}
-
void Screen_LoL::fprintString(const char *format, int x, int y, uint8 col1, uint8 col2, uint16 flags, ...) {
debugC(9, kDebugLevelScreen, "Screen_LoL::fprintString('%s', %d, %d, %d, %d, %d, ...)", format, x, y, col1, col2, flags);
if (!format)
diff --git a/engines/kyra/screen_lol.h b/engines/kyra/screen_lol.h
index 4de43788b1..abdc11d7c5 100644
--- a/engines/kyra/screen_lol.h
+++ b/engines/kyra/screen_lol.h
@@ -43,7 +43,6 @@ public:
const ScreenDim *getScreenDim(int dim);
int curDimIndex() { return _curDimIndex; }
void modifyScreenDim(int dim, int x, int y, int w, int h);
- void clearDim(int dim);
void fprintString(const char *format, int x, int y, uint8 col1, uint8 col2, uint16 flags, ...);
void fprintStringIntro(const char *format, int x, int y, uint8 c1, uint8 c2, uint8 c3, uint16 flags, ...);
@@ -77,7 +76,6 @@ public:
uint8 *_paletteOverlay2;
uint8 *_grayOverlay;
int _fadeFlag;
- int _dimLineCount;
private:
LoLEngine *_vm;
diff --git a/engines/kyra/script_lol.cpp b/engines/kyra/script_lol.cpp
index e6193c0b4e..c7dd99de29 100644
--- a/engines/kyra/script_lol.cpp
+++ b/engines/kyra/script_lol.cpp
@@ -471,7 +471,8 @@ int LoLEngine::olol_clearDialogueField(EMCState *script) {
_screen->setScreenDim(5);
const ScreenDim *d = _screen->getScreenDim(5);
_screen->fillRect(d->sx, d->sy, d->sx + d->w - 2, d->sy + d->h - 2, d->unkA);
- _screen->clearDim(4);
+ _txt->clearDim(4);
+ _txt->resetDimTextPositions(4);
return 1;
}
diff --git a/engines/kyra/script_tim.cpp b/engines/kyra/script_tim.cpp
index 89d32f1de4..8333d4c612 100644
--- a/engines/kyra/script_tim.cpp
+++ b/engines/kyra/script_tim.cpp
@@ -1131,18 +1131,12 @@ uint16 TIMInterpreter_LoL::processDialogue() {
if (!_vm->textEnabled() && _vm->_hideControls) {
_screen->setScreenDim(5);
const ScreenDim *d = _screen->getScreenDim(5);
- _screen->hideMouse();
_screen->fillRect(d->sx, d->sy + d->h - 9, d->sx + d->w - 1, d->sy + d->h - 1, d->unkA);
- _screen->showMouse();
} else {
const ScreenDim *d = _screen->_curDim;
- _screen->hideMouse();
_screen->fillRect(d->sx, d->sy, d->sx + d->w - 2, d->sy + d->h - 1, d->unkA);
- _screen->clearDim(4);
- _screen->setScreenDim(4);
- _screen->showMouse();
- //_screen->setDialogueColumn(8, 0);
- //_screen->setDialogueLine(8, 0);
+ _vm->_txt->clearDim(4);
+ _vm->_txt->resetDimTextPositions(4);
}
return res;
diff --git a/engines/kyra/sprites_lol.cpp b/engines/kyra/sprites_lol.cpp
index 52bebab931..7253d6ba32 100644
--- a/engines/kyra/sprites_lol.cpp
+++ b/engines/kyra/sprites_lol.cpp
@@ -325,7 +325,7 @@ void LoLEngine::assignMonsterToBlock(uint16 *assignedBlockObjects, int id) {
*assignedBlockObjects = id;
}
-int LoLEngine::checkBlockBeforeObjectPlacement(int x, int y, int monsterWidth, int testFlag, int wallFlag) {
+int LoLEngine::checkBlockBeforeObjectPlacement(int x, int y, int objectWidth, int testFlag, int wallFlag) {
_monsterLastWalkDirection = 0;
int x2 = 0;
int y2 = 0;
@@ -333,7 +333,7 @@ int LoLEngine::checkBlockBeforeObjectPlacement(int x, int y, int monsterWidth, i
int yOffs = 0;
int flag = 0;
- int r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y), x, y, monsterWidth, testFlag, wallFlag);
+ int r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y), x, y, objectWidth, testFlag, wallFlag);
if (r)
return r;
@@ -342,12 +342,12 @@ int LoLEngine::checkBlockBeforeObjectPlacement(int x, int y, int monsterWidth, i
return 4;
if (x & 0x80) {
- if (((x & 0xff) + monsterWidth) & 0xff00) {
+ if (((x & 0xff) + objectWidth) & 0xff00) {
xOffs = 1;
_monsterLastWalkDirection = 2;
- x2 = x + monsterWidth;
+ x2 = x + objectWidth;
- r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y), x, y, monsterWidth, testFlag, wallFlag);
+ r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y), x, y, objectWidth, testFlag, wallFlag);
if (r)
return r;
@@ -358,12 +358,12 @@ int LoLEngine::checkBlockBeforeObjectPlacement(int x, int y, int monsterWidth, i
flag = 1;
}
} else {
- if (((x & 0xff) - monsterWidth) & 0xff00) {
+ if (((x & 0xff) - objectWidth) & 0xff00) {
xOffs = -1;
_monsterLastWalkDirection = 6;
- x2 = x - monsterWidth;
+ x2 = x - objectWidth;
- r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y), x, y, monsterWidth, testFlag, wallFlag);
+ r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y), x, y, objectWidth, testFlag, wallFlag);
if (r)
return r;
@@ -376,12 +376,12 @@ int LoLEngine::checkBlockBeforeObjectPlacement(int x, int y, int monsterWidth, i
}
if (y & 0x80) {
- if (((y & 0xff) + monsterWidth) & 0xff00) {
+ if (((y & 0xff) + objectWidth) & 0xff00) {
yOffs = 1;
_monsterLastWalkDirection = 4;
- y2 = y + monsterWidth;
+ y2 = y + objectWidth;
- r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y2), x, y, monsterWidth, testFlag, wallFlag);
+ r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y2), x, y, objectWidth, testFlag, wallFlag);
if (r)
return r;
@@ -392,12 +392,12 @@ int LoLEngine::checkBlockBeforeObjectPlacement(int x, int y, int monsterWidth, i
flag = 0;
}
} else {
- if (((y & 0xff) - monsterWidth) & 0xff00) {
+ if (((y & 0xff) - objectWidth) & 0xff00) {
yOffs = -1;
_monsterLastWalkDirection = 0;
- y2 = y - monsterWidth;
+ y2 = y - objectWidth;
- r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y2), x, y, monsterWidth, testFlag, wallFlag);
+ r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x, y2), x, y, objectWidth, testFlag, wallFlag);
if (r)
return r;
@@ -412,7 +412,7 @@ int LoLEngine::checkBlockBeforeObjectPlacement(int x, int y, int monsterWidth, i
if (!flag)
return 0;
- r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y2), x, y, monsterWidth, testFlag, wallFlag);
+ r = checkBlockForWallsAndSufficientSpace(calcBlockIndex(x2, y2), x, y, objectWidth, testFlag, wallFlag);
if (r)
return r;
@@ -423,24 +423,7 @@ int LoLEngine::checkBlockBeforeObjectPlacement(int x, int y, int monsterWidth, i
return 0;
}
-int LoLEngine::calcMonsterSkillLevel(int id, int a) {
- const uint16 *c = getCharacterOrMonsterStats(id);
- int r = (a << 8) / c[4];
-
- if (!(id & 0x8000))
- r = (r * _monsterModifiers[3 + ((_unkGameFlag & 0x30) << 4)]) >> 8;
-
- id &= 0x7fff;
-
- if (_characters[id].skillLevels[1] <= 3)
- return r;
- else if (_characters[id].skillLevels[1] <= 7)
- return (r- (r >> 2));
-
- return (r- (r >> 1));
-}
-
-int LoLEngine::checkBlockForWallsAndSufficientSpace(int block, int x, int y, int monsterWidth, int testFlag, int wallFlag) {
+int LoLEngine::checkBlockForWallsAndSufficientSpace(int block, int x, int y, int objectWidth, int testFlag, int wallFlag) {
if (block == _currentBlock)
testFlag &= 0xfffe;
@@ -461,7 +444,7 @@ int LoLEngine::checkBlockForWallsAndSufficientSpace(int block, int x, int y, int
if (monster->mode < 13) {
int r = checkDrawObjectSpace(x, y, monster->x, monster->y);
- if ((monsterWidth + monster->properties->maxWidth) > r)
+ if ((objectWidth + monster->properties->maxWidth) > r)
return 2;
}
@@ -471,6 +454,23 @@ int LoLEngine::checkBlockForWallsAndSufficientSpace(int block, int x, int y, int
return 0;
}
+int LoLEngine::calcMonsterSkillLevel(int id, int a) {
+ const uint16 *c = getCharacterOrMonsterStats(id);
+ int r = (a << 8) / c[4];
+
+ if (!(id & 0x8000))
+ r = (r * _monsterModifiers[3 + ((_unkGameFlag & 0x30) << 4)]) >> 8;
+
+ id &= 0x7fff;
+
+ if (_characters[id].skillLevels[1] <= 3)
+ return r;
+ else if (_characters[id].skillLevels[1] <= 7)
+ return (r- (r >> 2));
+
+ return (r- (r >> 1));
+}
+
bool LoLEngine::checkBlockOccupiedByParty(int x, int y, int testFlag) {
if ((testFlag & 4) && (_currentBlock == calcBlockIndex(x, y)))
return true;
@@ -519,7 +519,7 @@ void LoLEngine::drawBlockObjects(int blockArrayIndex) {
if ((_itemProperties[i->itemPropertyIndex].flags & 0x1000) && !(i->shpCurFrame_flg & 0xC000)) {
int shpIndex = _itemProperties[i->itemPropertyIndex].flags & 0x800 ? 7 : _itemProperties[i->itemPropertyIndex].shpIndex;
-
+ shpIndex=12;
int ii = 0;
for (; ii < 8; ii++) {
if (!_flyingItems[ii].enable)
@@ -896,6 +896,7 @@ uint8 *LoLEngine::drawItemOrMonster(uint8 *shape, uint8 *table, int x, int y, in
ovl = _screen->getLevelOverlay(r);
} else {
memset (tmpOvl + 1, tblValue, 15);
+ tmpOvl[0] = 0;
table = tmpOvl;
ovl = _screen->getLevelOverlay(7);
}
diff --git a/engines/kyra/text_lol.cpp b/engines/kyra/text_lol.cpp
index 7b0024d62d..656f4b44c3 100644
--- a/engines/kyra/text_lol.cpp
+++ b/engines/kyra/text_lol.cpp
@@ -33,8 +33,8 @@
namespace Kyra {
TextDisplayer_LoL::TextDisplayer_LoL(LoLEngine *vm, Screen_LoL *screen) : _vm(vm), _screen(screen),
- _scriptParameter(0), _animWidth(0), _animColour1(0), _animColour2(0), _animFlag(true),
- _printFlag(false), _lineWidth(0), _numCharsTotal(0), _numCharsLeft(0), _numCharsPrinted(0), _posX(0), _posY(0), _colour1(0), _colour2(0) {
+ _scriptParameter(0), _animWidth(0), _animColour1(0), _animColour2(0), _animFlag(true), _lineCount(0),
+ _printFlag(false), _lineWidth(0), _numCharsTotal(0), _numCharsLeft(0), _numCharsPrinted(0) {
memset(_stringParameters, 0, 15 * sizeof(char*));
_buffer = new char[600];
@@ -45,6 +45,14 @@ TextDisplayer_LoL::TextDisplayer_LoL(LoLEngine *vm, Screen_LoL *screen) : _vm(vm
_currentLine = new char[85];
memset(_currentLine, 0, 85);
+
+ for (int i = 0; i < 14; i++){
+ const ScreenDim *d = _screen->getScreenDim(i);
+ _textDimData[i].color1 = d->unk8;
+ _textDimData[i].color2 = d->unkA;
+ _textDimData[i].line = d->unkC;
+ _textDimData[i].column = d->unkE;
+ }
}
TextDisplayer_LoL::~TextDisplayer_LoL() {
@@ -61,7 +69,7 @@ void TextDisplayer_LoL::setupField(bool mode) {
_screen->copyRegionToBuffer(3, 0, 0, 320, 40, _vm->_pageBuffer2);
_screen->copyBlockToPage(3, 0, 0, 320, 40, _vm->_pageBuffer1);
} else {
- _screen->clearDim(4);
+ _screen->setScreenDim(clearDim(4));
int cp = _screen->setCurPage(2);
_screen->copyRegionToBuffer(3, 0, 0, 320, 40, _vm->_pageBuffer1);
_screen->copyBlockToPage(3, 0, 0, 320, 40, _vm->_pageBuffer2);
@@ -84,7 +92,7 @@ void TextDisplayer_LoL::setupField(bool mode) {
}
} else {
if (!mode)
- _screen->clearDim(4);
+ _screen->setScreenDim(clearDim(4));
_vm->toggleSelectedCharacterFrame(1);
}
}
@@ -96,7 +104,7 @@ void TextDisplayer_LoL::expandField() {
_vm->_fadeText = false;
_vm->_textColourFlag = 0;
_vm->_timer->disable(11);
- _screen->clearDim(3);
+ _screen->setScreenDim(clearDim(3));
_screen->copyRegionToBuffer(3, 0, 0, 320, 10, tmp);
_screen->copyRegion(83, 140, 0, 0, 235, 3, 0, 2, Screen::CR_NO_P_CHECK);
@@ -113,10 +121,25 @@ void TextDisplayer_LoL::expandField() {
_vm->_updateFlags |= 2;
} else {
- _screen->clearDim(3);
+ clearDim(3);
_vm->toggleSelectedCharacterFrame(0);
}
}
+
+int TextDisplayer_LoL::clearDim(int dim) {
+ int res = _screen->curDimIndex();
+ _screen->setScreenDim(dim);
+ _textDimData[dim].color1 = _screen->_curDim->unk8;
+ _textDimData[dim].color2 = _screen->_curDim->unkA;
+ clearCurDim();
+ return res;
+}
+
+void TextDisplayer_LoL::resetDimTextPositions(int dim) {
+ _textDimData[dim].column = 0;
+ _textDimData[dim].line = 0;
+}
+
void TextDisplayer_LoL::setAnimParameters(const char *str, int x, uint8 col1, uint8 col2) {
static const char defaultStr[] = "<MORE>";
@@ -134,29 +157,23 @@ void TextDisplayer_LoL::setAnimParameters(const char *str, int x, uint8 col1, ui
}
void TextDisplayer_LoL::printDialogueText(int dim, char *str, EMCState *script, const uint16 *paramList, int16 paramIndex) {
- _colour1prot = false;
- int oldDim = _screen->curDimIndex();
+ int oldDim = 0;
if (dim == 3) {
if (_vm->_updateFlags & 2) {
- _screen->setScreenDim(4);
- _screen->clearDim(4);
- _colour1 = 254;
- _colour1prot = true;
+ oldDim = clearDim(4);
+ _textDimData[4].color1 = 254;
} else {
- _screen->setScreenDim(3);
- _screen->clearDim(3);
- _colour1 = 192;
- _colour1prot = true;
+ oldDim = clearDim(3);
+ _textDimData[3].color1 = 192;
_screen->copyColour(192, 254);
_vm->enableTimer(11);
_vm->_textColourFlag = 0;
_vm->_fadeText = false;
}
} else {
- _screen->setScreenDim(dim);
- _colour1 = 254;
- _colour1prot = true;
+ oldDim = clearDim(dim);
+ _textDimData[dim].color1 = 254;
}
int cp = _screen->setCurPage(0);
@@ -186,18 +203,14 @@ void TextDisplayer_LoL::printMessage(uint16 type, char *str, ...) {
int od = _screen->curDimIndex();
if (_vm->_updateFlags & 2) {
- _screen->setScreenDim(4);
- clearCurDim();
- _colour1 = col;
+ clearDim(4);
+ _textDimData[4].color1 = col;
} else {
- _screen->setScreenDim(3);
- clearCurDim();
+ clearDim(3);
_screen->copyColour(192, col);
- _colour1 = 192;
+ _textDimData[3].color1 = 192;
_vm->enableTimer(11);
}
-
- _colour1prot = true;
va_list args;
va_start(args, str);
@@ -330,18 +343,13 @@ void TextDisplayer_LoL::displayText(char *str, ...) {
memset(_ctrl, 0, 3);
- if (!_colour1prot)
- _colour1 = _screen->_curDim->unk8;
- _colour2 = _screen->_curDim->unkA;
- _posX = _screen->_curDim->unkC;
- _posY = _screen->_curDim->unkE;
-
char c = parseCommand();
va_list args;
va_start(args, str);
const ScreenDim *sd = _screen->_curDim;
+ int sdx = _screen->curDimIndex();
while (c) {
char a = tolower(_ctrl[1]);
@@ -370,12 +378,12 @@ void TextDisplayer_LoL::displayText(char *str, ...) {
case 1:
printLine(_currentLine);
- _colour2 = parseCommand();
+ _textDimData[sdx].color2 = parseCommand();
break;
case 5:
printLine(_currentLine);
- _colour1 = parseCommand();
+ _textDimData[sdx].color1 = parseCommand();
break;
case 8:
@@ -388,9 +396,9 @@ void TextDisplayer_LoL::displayText(char *str, ...) {
case 12:
printLine(_currentLine);
- _screen->_dimLineCount++;
- _posX = 0;
- _posY++;
+ _lineCount++;
+ _textDimData[sdx].column = 0;
+ _textDimData[sdx].line++;
break;
case 18:
@@ -418,7 +426,7 @@ void TextDisplayer_LoL::displayText(char *str, ...) {
_currentLine[_numCharsLeft++] = c;
_currentLine[_numCharsLeft] = 0;
- if ((_posX + _lineWidth) > (sd->w << 3))
+ if ((_textDimData[sdx].column + _lineWidth) > (sd->w << 3))
printLine(_currentLine);
break;
@@ -472,13 +480,14 @@ void TextDisplayer_LoL::readNextPara() {
void TextDisplayer_LoL::printLine(char *str) {
const ScreenDim *sd = _screen->_curDim;
+ int sdx = _screen->curDimIndex();
int fh = (_screen->getFontHeight() + _screen->_charOffset);
int lines = (sd->h - _screen->_charOffset) / fh;
- while (_posY >= lines) {
- if (lines <= _screen->_dimLineCount && _animFlag) {
- _screen->_dimLineCount = 0;
+ while (_textDimData[sdx].line >= lines) {
+ if (lines <= _lineCount && _animFlag) {
+ _lineCount = 0;
textPageBreak();
_numCharsPrinted = 0;
}
@@ -489,23 +498,23 @@ void TextDisplayer_LoL::printLine(char *str) {
if (h2)
_screen->copyRegion(sd->sx << 3, sd->sy + fh, sd->sx << 3, sd->sy, sd->w << 3, h2, _screen->_curPage, _screen->_curPage, Screen::CR_NO_P_CHECK);
- _screen->fillRect(sd->sx << 3, sd->sy + h1, (sd->sx + sd->w - 1) << 3, sd->sy + sd->h - 1, _colour2);
- if (_posY)
- _posY--;
+ _screen->fillRect(sd->sx << 3, sd->sy + h1, (sd->sx + sd->w - 1) << 3, sd->sy + sd->h - 1, _textDimData[sdx].color2);
+ if (_textDimData[sdx].line)
+ _textDimData[sdx].line--;
}
- int x1 = (sd->sx << 3) + _posX;
- int y = sd->sy + fh * _posY;
+ int x1 = (sd->sx << 3) + _textDimData[sdx].column;
+ int y = sd->sy + fh * _textDimData[sdx].line;
int w = sd->w << 3;
int lw = _lineWidth;
int s = _numCharsLeft;
char c = 0;
- if ((lw + _posX) > w) {
- if ((lines - 1) <= _screen->_dimLineCount && _animFlag)
+ if ((lw + _textDimData[sdx].column) > w) {
+ if ((lines - 1) <= _lineCount && _animFlag)
w -= (_animWidth * (_screen->getFontWidth() + _screen->_charWidth));
- w -= _posX;
+ w -= _textDimData[sdx].column;
int n2 = 0;
int n1 = s - 1;
@@ -528,7 +537,7 @@ void TextDisplayer_LoL::printLine(char *str) {
}
if (!n1) {
- if (_posX && !_printFlag) {
+ if (_textDimData[sdx].column && !_printFlag) {
s = lw = 0;
_printFlag = true;
} else {
@@ -540,8 +549,8 @@ void TextDisplayer_LoL::printLine(char *str) {
c = str[s];
str[s] = 0;
- _screen->printText(str, x1, y, _colour1, _colour2);
- _posX += lw;
+ _screen->printText(str, x1, y, _textDimData[sdx].color1, _textDimData[sdx].color2);
+ _textDimData[sdx].column += lw;
_numCharsPrinted += strlen(str);
str[s] = c;
@@ -560,12 +569,12 @@ void TextDisplayer_LoL::printLine(char *str) {
_numCharsLeft = strlen(str);
_lineWidth = _screen->getTextWidth(str);
- if (!_numCharsLeft && _posX < (sd->w << 3))
+ if (!_numCharsLeft && _textDimData[sdx].column < (sd->w << 3))
return;
- _posX = 0;
- _posY++;
- _screen->_dimLineCount++;
+ _textDimData[sdx].column = 0;
+ _textDimData[sdx].line++;
+ _lineCount++;
printLine(str);
}
@@ -661,7 +670,8 @@ void TextDisplayer_LoL::textPageBreak() {
}
} while (loop);
- _screen->fillRect(x, y, x + 74, y + 9, _colour2);
+
+ _screen->fillRect(x, y, x + 74, y + 9, _textDimData[_screen->curDimIndex()].color2);
clearCurDim();
_vm->_timer->pauseSingleTimer(11, false);
@@ -682,10 +692,11 @@ void TextDisplayer_LoL::textPageBreak() {
}
void TextDisplayer_LoL::clearCurDim() {
+ int d = _screen->curDimIndex();
const ScreenDim *tmp = _screen->getScreenDim(_screen->curDimIndex());
- _screen->fillRect(tmp->sx << 3, tmp->sy, ((tmp->sx + tmp->w) << 3) - 1, (tmp->sy + tmp->h) - 1, _colour2);
- _screen->_dimLineCount = 0;
- _posX = _posY = 0;
+ _screen->fillRect(tmp->sx << 3, tmp->sy, ((tmp->sx + tmp->w) << 3) - 1, (tmp->sy + tmp->h) - 1, _textDimData[d].color2);
+ _lineCount = 0;
+ _textDimData[d].column = _textDimData[d].line = 0;
}
} // end of namespace Kyra
diff --git a/engines/kyra/text_lol.h b/engines/kyra/text_lol.h
index ee747c5f03..950f17cc2c 100644
--- a/engines/kyra/text_lol.h
+++ b/engines/kyra/text_lol.h
@@ -46,6 +46,9 @@ public:
void setupField(bool mode);
void expandField();
+ int clearDim(int dim);
+ void resetDimTextPositions(int dim);
+
void printDialogueText(int dim, char *str, EMCState *script, const uint16 *paramList, int16 paramIndex);
void printMessage(uint16 type, char *str, ...);
@@ -72,6 +75,7 @@ private:
char _scriptParaString[11];
uint16 _lineWidth;
+ int _lineCount;
uint32 _numCharsTotal;
uint32 _numCharsLeft;
uint32 _numCharsPrinted;
@@ -84,14 +88,17 @@ private:
bool _animFlag;
bool _printFlag;
- uint8 _posX;
- uint8 _posY;
- uint8 _colour1;
- uint8 _colour2;
- bool _colour1prot;
-
LoLEngine *_vm;
Screen_LoL *_screen;
+
+ struct TextDimData {
+ uint8 color1;
+ uint8 color2;
+ uint8 column;
+ uint8 line;
+ };
+
+ TextDimData _textDimData[14];
};
} // end of namespace Kyra