aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/scene_eob.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/kyra/scene_eob.cpp')
-rw-r--r--engines/kyra/scene_eob.cpp98
1 files changed, 24 insertions, 74 deletions
diff --git a/engines/kyra/scene_eob.cpp b/engines/kyra/scene_eob.cpp
index 3db055db90..45de232cb6 100644
--- a/engines/kyra/scene_eob.cpp
+++ b/engines/kyra/scene_eob.cpp
@@ -100,7 +100,7 @@ void EoBCoreEngine::loadLevel(int level, int sub) {
void EoBCoreEngine::readLevelFileData(int level) {
Common::String file;
Common::SeekableReadStream *s = 0;
- static const char *suffix[] = { "INF", "DRO", "ELO", 0 };
+ static const char *const suffix[] = { "INF", "DRO", "ELO", 0 };
for (const char *const *sf = suffix; *sf && !s; sf++) {
file = Common::String::format("LEVEL%d.%s", level, *sf);
@@ -144,10 +144,10 @@ Common::String EoBCoreEngine::initLevelData(int sub) {
const char *vmpPattern = (_flags.gameID == GI_EOB1 && (_configRenderMode == Common::kRenderEGA || _configRenderMode == Common::kRenderCGA)) ? "%s.EMP" : "%s.VMP";
Common::SeekableReadStream *s = _res->createReadStream(Common::String::format(vmpPattern, (const char *)pos));
- _vmpSize = s->readUint16LE();
+ uint16 size = s->readUint16LE();
delete[] _vmpPtr;
- _vmpPtr = new uint16[_vmpSize];
- for (int i = 0; i < _vmpSize; i++)
+ _vmpPtr = new uint16[size];
+ for (int i = 0; i < size; i++)
_vmpPtr[i] = s->readUint16LE();
delete s;
@@ -157,7 +157,7 @@ Common::String EoBCoreEngine::initLevelData(int sub) {
_curGfxFile = (const char *)pos;
pos += slen;
- if (*pos++ != 0xff && _flags.gameID == GI_EOB2) {
+ if (*pos++ != 0xFF && _flags.gameID == GI_EOB2) {
tmpStr = Common::String::format(paletteFilePattern, (const char *)pos);
pos += 13;
}
@@ -174,7 +174,7 @@ Common::String EoBCoreEngine::initLevelData(int sub) {
if (_configRenderMode != Common::kRenderCGA) {
Palette backupPal(256);
backupPal.copy(_screen->getPalette(0), 224, 32, 224);
- _screen->getPalette(0).fill(224, 32, 0x3f);
+ _screen->getPalette(0).fill(224, 32, 0x3F);
uint8 *src = _screen->getPalette(0).getData();
_screen->createFadeTable(src, _screen->getFadeTable(0), 4, 75); // green
@@ -259,7 +259,7 @@ Common::String EoBCoreEngine::initLevelData(int sub) {
}
if (_flags.gameID == GI_EOB2)
- pos = initScriptTimers(pos);
+ initScriptTimers(pos);
return _curGfxFile;
}
@@ -271,7 +271,7 @@ void EoBCoreEngine::addLevelItems() {
for (int i = 0; i < 600; i++) {
if (_items[i].level != _currentLevel || _items[i].block <= 0)
continue;
- setItemPosition((Item *)&_levelBlockProperties[_items[i].block & 0x3ff].drawObjects, _items[i].block, i, _items[i].pos);
+ setItemPosition((Item *)&_levelBlockProperties[_items[i].block & 0x3FF].drawObjects, _items[i].block, i, _items[i].pos);
}
}
@@ -283,7 +283,7 @@ void EoBCoreEngine::loadVcnData(const char *file, const uint8 *cgaMapping) {
_screen->loadBitmap(Common::String::format(filePattern, _lastBlockDataFile).c_str(), 3, 3, 0);
const uint8 *pos = _screen->getCPagePtr(3);
- uint32 vcnSize = READ_LE_UINT16(pos) * _vcnBlockWidth * _vcnBlockHeight;
+ uint32 vcnSize = READ_LE_UINT16(pos) << 5;
pos += 2;
const uint8 *colMap = pos;
@@ -292,78 +292,28 @@ void EoBCoreEngine::loadVcnData(const char *file, const uint8 *cgaMapping) {
delete[] _vcnBlocks;
_vcnBlocks = new uint8[vcnSize];
- if (_flags.gameID == GI_EOB2 && _configRenderMode == Common::kRenderEGA) {
- const uint8 *egaTable = _screen->getEGADitheringTable();
- assert(_vmpPtr);
- assert(egaTable);
-
- delete[] _vcnTransitionMask;
- _vcnTransitionMask = new uint8[vcnSize];
-
- for (int i = 0; i < _vmpSize; i++) {
- uint16 vcnOffs = _vmpPtr[i] & 0x3FFF;
- const uint8 *src = &pos[vcnOffs << 5];
- uint8 *dst1 = &_vcnBlocks[vcnOffs << 7];
- uint8 *dst3 = &_vcnTransitionMask[vcnOffs << 7];
- int palOffset = (i < 330) ? 0 : _wllVcnOffset;
-
- for (int y = 0; y < 8; y++) {
- uint8 *dst2 = dst1 + 8;
- uint8 *dst4 = dst3 + 8;
-
- for (int x = 0; x < 4; x++) {
- uint8 in = *src++;
-
- dst1[0] = dst2[0] = egaTable[colMap[(in >> 4) + palOffset]];
- dst1[1] = dst2[1] = egaTable[colMap[(in & 0x0f) + palOffset]];
- dst3[0] = dst4[0] = (in & 0xf0) ? 0 : 0xff;
- dst3[1] = dst4[1] = (in & 0x0f) ? 0 : 0xff;
-
- dst1 += 2;
- dst2 += 2;
- dst3 += 2;
- dst4 += 2;
- }
-
- dst1 += 8;
- dst3 += 8;
- }
- }
- } else if (_configRenderMode == Common::kRenderCGA) {
+ if (_configRenderMode == Common::kRenderCGA) {
uint8 *tmp = _screen->encodeShape(0, 0, 1, 8, false, cgaMapping);
delete[] tmp;
delete[] _vcnTransitionMask;
_vcnTransitionMask = new uint8[vcnSize];
- uint8 tblSwitch = 0;
+ uint8 tblSwitch = 1;
uint8 *dst = _vcnBlocks;
uint8 *dst2 = _vcnTransitionMask;
while (dst < _vcnBlocks + vcnSize) {
const uint16 *table = _screen->getCGADitheringTable((tblSwitch++) & 1);
for (int ii = 0; ii < 2; ii++) {
- *dst++ = ((table[pos[0]] & 0x000f) << 4) | ((table[pos[0]] & 0x0f00) >> 8);
- *dst++= ((table[pos[1]] & 0x000f) << 4) | ((table[pos[1]] & 0x0f00) >> 8);
-
- uint8 msk = 0;
- if (pos[0] & 0xf0)
- msk |= 0x30;
- if (pos[0] & 0x0f)
- msk |= 0x03;
- *dst2++ = msk ^ 0x33;
-
- msk = 0;
- if (pos[1] & 0xf0)
- msk |= 0x30;
- if (pos[1] & 0x0f)
- msk |= 0x03;
- *dst2++ = msk ^ 0x33;
-
+ *dst++ = (table[pos[0]] & 0x000F) | ((table[pos[0]] & 0x0F00) >> 4);
+ *dst++ = (table[pos[1]] & 0x000F) | ((table[pos[1]] & 0x0F00) >> 4);
+ *dst2++ = ((pos[0] & 0xF0 ? 0x30 : 0) | (pos[0] & 0x0F ? 0x03 : 0)) ^ 0x33;
+ *dst2++ = ((pos[1] & 0xF0 ? 0x30 : 0) | (pos[1] & 0x0F ? 0x03 : 0)) ^ 0x33;
pos += 2;
}
}
} else {
- if (_configRenderMode != Common::kRenderEGA)
+ if (!(_flags.gameID == GI_EOB1 && _configRenderMode == Common::kRenderEGA))
memcpy(_vcnColTable, colMap, 32);
memcpy(_vcnBlocks, pos, vcnSize);
}
@@ -429,8 +379,8 @@ void EoBCoreEngine::loadDecorations(const char *cpsFile, const char *decFile) {
LevelDecorationProperty *l = &_levelDecorationData[i];
for (int ii = 0; ii < 10; ii++) {
l->shapeIndex[ii] = s->readByte();
- if (l->shapeIndex[ii] == 0xff)
- l->shapeIndex[ii] = 0xffff;
+ if (l->shapeIndex[ii] == 0xFF)
+ l->shapeIndex[ii] = 0xFFFF;
}
l->next = s->readByte();
l->flags = s->readByte();
@@ -477,7 +427,7 @@ void EoBCoreEngine::assignWallsAndDecorations(int wallIndex, int vmpIndex, int d
for (int i = 0; i < 10; i++) {
uint16 t = _levelDecorationProperties[_mappedDecorationsCount].shapeIndex[i];
- if (t == 0xffff)
+ if (t == 0xFFFF)
continue;
if (_levelDecorationShapes[t])
@@ -529,7 +479,7 @@ void EoBCoreEngine::toggleWallState(int wall, int toggle) {
if (toggle)
_wllWallFlags[wall + i] |= 2;
else
- _wllWallFlags[wall + i] &= 0xfd;
+ _wllWallFlags[wall + i] &= 0xFD;
}
}
@@ -643,7 +593,7 @@ void EoBCoreEngine::drawDecorations(int index) {
if ((i == 0) && (flg & 1 || ((flg & 2) && _wllProcessFlag)))
ix = -ix;
- if (_levelDecorationProperties[l].shapeIndex[shpIx] == 0xffff) {
+ if (_levelDecorationProperties[l].shapeIndex[shpIx] == 0xFFFF) {
l = _levelDecorationProperties[l].next;
continue;
}
@@ -758,7 +708,7 @@ int EoBCoreEngine::clickedNiche(uint16 block, uint16 direction) {
if (_dscItemShapeMap[_items[_itemInHand].icon] <= 14) {
_txt->printMessage(_pryDoorStrings[5]);
} else {
- setItemPosition((Item *)&_levelBlockProperties[block & 0x3ff].drawObjects, block, _itemInHand, 8);
+ setItemPosition((Item *)&_levelBlockProperties[block & 0x3FF].drawObjects, block, _itemInHand, 8);
runLevelScript(block, 4);
setHandItem(0);
_sceneUpdateRequired = true;
@@ -781,7 +731,7 @@ int EoBCoreEngine::clickedDoorPry(uint16 block, uint16 direction) {
int d = -1;
for (int i = 0; i < 6; i++) {
- if (!testCharacter(i, 0x0d))
+ if (!testCharacter(i, 0x0D))
continue;
if (d >= 0) {
int s1 = _characters[i].strengthCur + _characters[i].strengthExtCur;
@@ -826,7 +776,7 @@ int EoBCoreEngine::clickedDoorNoPry(uint16 block, uint16 direction) {
int EoBCoreEngine::specialWallAction(int block, int direction) {
direction ^= 2;
uint8 type = _specialWallTypes[_levelBlockProperties[block].walls[direction]];
- if (!type || !(_clickedSpecialFlag & (((_levelBlockProperties[block].flags & 0xf8) >> 3) | 0xe0)))
+ if (!type || !(_clickedSpecialFlag & (((_levelBlockProperties[block].flags & 0xF8) >> 3) | 0xE0)))
return 0;
int res = 0;