aboutsummaryrefslogtreecommitdiff
path: root/engines/igor
diff options
context:
space:
mode:
Diffstat (limited to 'engines/igor')
-rw-r--r--engines/igor/detection.cpp55
-rw-r--r--engines/igor/igor.cpp241
-rw-r--r--engines/igor/igor.h30
-rw-r--r--engines/igor/parts/part_13.cpp6
-rw-r--r--engines/igor/parts/part_15.cpp16
-rw-r--r--engines/igor/parts/part_36.cpp20
-rw-r--r--engines/igor/parts/part_85.cpp2
7 files changed, 175 insertions, 195 deletions
diff --git a/engines/igor/detection.cpp b/engines/igor/detection.cpp
index 7d73c53f74..2b52270f4b 100644
--- a/engines/igor/detection.cpp
+++ b/engines/igor/detection.cpp
@@ -33,13 +33,14 @@
struct GameDetectVersion {
uint32 borlandOverlaySize;
- const char *versionString;
+ int gameVersion;
+ Common::Language language;
+ const char *descriptionSuffix;
};
static const GameDetectVersion igorDetectVersionsTable[] = {
- { 4086790, " 1.00s" },
- { 4094103, " 1.10s" },
- { 0, 0 }
+ { 4086790, Igor::kIdEngDemo100, Common::EN_ANY, " 1.00s" },
+ { 4094103, Igor::kIdEngDemo110, Common::EN_ANY, " 1.10s" }
};
static const char *igorDetectFileName = "IGOR.DAT";
@@ -61,33 +62,35 @@ GameDescriptor Engine_IGOR_findGameID(const char *gameid) {
return GameDescriptor();
}
-GameList Engine_IGOR_detectGames(const FSList &fslist) {
- GameList detectedGames;
+static const GameDetectVersion *Engine_IGOR_findGameVersion(const FSList &fslist) {
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- if (file->isDirectory()) {
+ if (file->isDirectory() || !file->getName().equalsIgnoreCase(igorDetectFileName)) {
continue;
}
- if (file->getName().equalsIgnoreCase(igorDetectFileName)) {
- Common::File f;
- if (!f.open(*file)) {
- continue;
- }
- const uint32 sig = f.readUint32BE();
- if (sig == MKID_BE('FBOV')) {
- const uint32 fileSize = f.size();
- for (int i = 0; igorDetectVersionsTable[i].borlandOverlaySize; ++i) {
- if (igorDetectVersionsTable[i].borlandOverlaySize != fileSize) {
- continue;
+ Common::File f;
+ if (f.open(*file)) {
+ const uint32 fileSize = f.size();
+ if (f.readUint32BE() == MKID_BE('FBOV')) {
+ for (int i = 0; i < ARRAYSIZE(igorDetectVersionsTable); ++i) {
+ if (igorDetectVersionsTable[i].borlandOverlaySize == fileSize) {
+ return &igorDetectVersionsTable[i];
}
- GameDescriptor gd(igorGameDescriptor.gameid, igorGameDescriptor.description, Common::EN_ANY, Common::kPlatformPC);
- gd.description() += igorDetectVersionsTable[i].versionString;
- gd.updateDesc("Demo");
- detectedGames.push_back(gd);
- break;
}
}
}
}
+ return 0;
+}
+
+GameList Engine_IGOR_detectGames(const FSList &fslist) {
+ GameList detectedGames;
+ const GameDetectVersion *gdv = Engine_IGOR_findGameVersion(fslist);
+ if (gdv) {
+ GameDescriptor gd(igorGameDescriptor.gameid, igorGameDescriptor.description, gdv->language, Common::kPlatformPC);
+ gd.description() += gdv->descriptionSuffix;
+ gd.updateDesc("Demo");
+ detectedGames.push_back(gd);
+ }
return detectedGames;
}
@@ -97,12 +100,12 @@ PluginError Engine_IGOR_create(OSystem *system, Engine **engine) {
if (!dir.getChildren(fslist, FilesystemNode::kListFilesOnly)) {
return kInvalidPathError;
}
- GameList gameList = Engine_IGOR_detectGames(fslist);
- if (gameList.size() != 1) {
+ const GameDetectVersion *gdv = Engine_IGOR_findGameVersion(fslist);
+ if (!gdv) {
return kNoGameDataFoundError;
}
assert(engine);
- *engine = new Igor::IgorEngine(system);
+ *engine = new Igor::IgorEngine(system, gdv->gameVersion);
return kNoError;
}
diff --git a/engines/igor/igor.cpp b/engines/igor/igor.cpp
index 580f8f6bd8..aa314e2898 100644
--- a/engines/igor/igor.cpp
+++ b/engines/igor/igor.cpp
@@ -35,8 +35,8 @@
namespace Igor {
-IgorEngine::IgorEngine(OSystem *system)
- : Engine(system) {
+IgorEngine::IgorEngine(OSystem *system, int gameVersion)
+ : Engine(system), _gameVersion(gameVersion) {
_screenVGA = (uint8 *)malloc(320 * 200);
for (int i = 0; i < 4; ++i) {
@@ -160,7 +160,10 @@ int IgorEngine::go() {
if (!_sndFile.open("IGOR.FSD")) {
error("Unable to open 'IGOR.FSD'");
}
- readResourceEntriesTable();
+ if (!_tblFile.open("IGOR.TBL")) {
+ error("Unable to open 'IGOR.TBL'");
+ }
+ readResourceTableFile();
loadMainTexts();
loadIgorFrames();
_gameState.talkMode = kTalkModeTextOnly;
@@ -170,37 +173,26 @@ int IgorEngine::go() {
PART_MAIN();
_ovlFile.close();
_sndFile.close();
- delete[] _resourceEntriesTable;
+ _tblFile.close();
return 0;
}
-void IgorEngine::readResourceEntriesTable() {
- Common::File f;
- if (f.open("IGOR.TBL") && f.readUint32BE() == MKID_BE('ITBL') && f.readUint32BE() == 1) {
- bool foundVersion = false;
+void IgorEngine::readResourceTableFile() {
+ if (_tblFile.readUint32BE() == MKID_BE('ITBL') && _tblFile.readUint32BE() == 1) {
uint32 borlandOverlaySize = _ovlFile.size();
- int gameVersionsCount = f.readByte();
+ int gameVersionsCount = _tblFile.readByte();
for (int i = 0; i < gameVersionsCount; ++i) {
- uint32 size = f.readUint32BE();
- uint32 offs = f.readUint32BE();
+ uint32 size = _tblFile.readUint32BE();
+ uint32 offs = _tblFile.readUint32BE();
if (size == borlandOverlaySize) {
- f.seek(offs);
- foundVersion = true;
- break;
+ _tblFile.seek(offs);
+ _resourceEntriesCount = _tblFile.readUint16BE();
+ _resourceEntriesOffset = offs + 2;
+ return;
}
}
- assert(foundVersion);
- _resourceEntriesCount = f.readUint16BE();
- _resourceEntriesTable = new ResourceEntry[_resourceEntriesCount];
- for (int i = 0; i < _resourceEntriesCount; ++i) {
- ResourceEntry *re = &_resourceEntriesTable[i];
- re->id = f.readUint16BE();
- re->offs = f.readUint32BE();
- re->size = f.readUint32BE();
- }
- } else {
- error("Unable to open 'IGOR.TBL'");
}
+ error("Unable to read 'IGOR.TBL'");
}
void IgorEngine::waitForTimer(int ticks) {
@@ -466,7 +458,7 @@ void IgorEngine::waitForEndOfCutsceneDialogue(int x, int y, int r, int g, int b)
}
if (compareGameTick(19, 32) && _gameState.dialogueTextRunning) {
if (_talkSpeechCounter > 2) {
- if (_gameState.talkMode < 2) {
+ if (_gameState.talkMode != kTalkModeTextOnly) {
_talkDelayCounter = _talkDelay;
}
if (_talkDelay == _talkDelayCounter) {
@@ -478,7 +470,7 @@ void IgorEngine::waitForEndOfCutsceneDialogue(int x, int y, int r, int g, int b)
_gameState.dialogueTextRunning = 0;
} else {
++_dialogueTextsStart;
- if (_gameState.talkMode < 2) {
+ if (_gameState.talkMode != kTalkModeTextOnly) {
if (_talkSpeechCounter != -1) {
_talkSpeechCounter = 0;
} else {
@@ -551,17 +543,17 @@ void IgorEngine::startIgorDialogue() {
}
setPaletteColor(kTalkColor, _dialogueColor[0], _dialogueColor[1], _dialogueColor[2]);
setPaletteColor(kTalkShadowColor, 0, 0, 0);
- if (_gameState.talkMode > 0) {
+ if (_gameState.talkMode != kTalkModeSpeechOnly) {
memcpy(_screenVGA + _dialogueDirtyRectY, _screenTextLayer, _dialogueDirtyRectSize);
}
- if (_gameState.talkMode == 2) {
+ if (_gameState.talkMode == kTalkModeTextOnly) {
_talkDelay = (2 * dt->count) * _talkDelays[_gameState.talkSpeed];
_talkDelayCounter = 0;
} else {
_talkDelay = -1;
_talkDelayCounter = 0;
}
- if (_gameState.talkMode >= 2) {
+ if (_gameState.talkMode == kTalkModeTextOnly) {
playSound(24, 0);
}
_gameState.dialogueTextRunning = true;
@@ -576,7 +568,7 @@ void IgorEngine::waitForEndOfIgorDialogue() {
}
if (compareGameTick(19, 32) && _gameState.dialogueTextRunning) {
if (_talkSpeechCounter > 2) {
- if (_gameState.talkMode < 2) {
+ if (_gameState.talkMode != kTalkModeTextOnly) {
_talkDelayCounter = _talkDelay;
}
if (_talkDelay == _talkDelayCounter) {
@@ -586,7 +578,7 @@ void IgorEngine::waitForEndOfIgorDialogue() {
_gameState.dialogueTextRunning = 0;
} else {
++_dialogueTextsStart;
- if (_gameState.talkMode < 2) {
+ if (_gameState.talkMode != kTalkModeTextOnly) {
if (_talkSpeechCounter != -1) {
_talkSpeechCounter = 0;
} else {
@@ -626,40 +618,30 @@ int IgorEngine::getObjectFromInventory(int x) const {
return 0;
}
-int IgorEngine::getSelectedVerb() const {
- for (int i = 0; i <= 6; ++i) {
- for (int w = 0; w <= 19; ++w) {
- const uint8 *p = _screenVGA + 320 * 156 + i * 46 + w;
- if (*p == 251) {
- return i + 2;
- }
- }
- }
- return 0;
-}
-
-const ResourceEntry *IgorEngine::findData(int id) const {
- --id;
- assert(id >= 0 && id < _resourceEntriesCount);
- const ResourceEntry *re = &_resourceEntriesTable[id];
- assert(re->id == id + 1);
+ResourceEntry IgorEngine::findData(int id) {
+ assert(id >= 1 && id <= _resourceEntriesCount);
+ _tblFile.seek(_resourceEntriesOffset + (id - 1) * 10);
+ ResourceEntry re;
+ re.id = _tblFile.readUint16BE();
+ re.offs = _tblFile.readUint32BE();
+ re.size = _tblFile.readUint32BE();
+ assert(re.id == id);
return re;
}
uint8 *IgorEngine::loadData(int id, uint8 *dst, int *size) {
- const ResourceEntry *re = findData(id);
- assert(re);
- debug(kDebugResource, "loadData() id %d offset %d size %d", id, re->offs, re->size);
+ ResourceEntry re = findData(id);
+ debug(kDebugResource, "loadData() id %d offset %d size %d", id, re.offs, re.size);
if (!dst) {
- dst = (uint8 *)malloc(re->size);
+ dst = (uint8 *)malloc(re.size);
if (!dst) {
- error("Unable to allocate %d bytes", re->size);
+ error("Unable to allocate %d bytes", re.size);
}
}
- _ovlFile.seek(re->offs);
- _ovlFile.read(dst, re->size);
+ _ovlFile.seek(re.offs);
+ _ovlFile.read(dst, re.size);
if (size) {
- *size = re->size;
+ *size = re.size;
}
return dst;
}
@@ -814,7 +796,7 @@ void IgorEngine::loadAnimData(const int *anm, int loadOffset) {
void IgorEngine::loadActionData(int act) {
if (act != 0) {
- assert(findData(act)->size <= 0x2000);
+ assert(findData(act).size <= 0x2000);
loadData(act, _roomActionsTable);
}
}
@@ -1146,44 +1128,42 @@ void IgorEngine::updateRoomLight(int fl) {
return;
}
offset += x;
+ RoomObjectArea *roa;
int color = (fl == 0) ? 196 : 195;
switch (wd->posNum) {
- case 2: {
- RoomObjectArea *roa = &_roomObjectAreasTable[_screenLayer2[offset + 1298]];
- if (wd->y > roa->y1Lum) {
- if (wd->y <= roa->y2Lum && _gameState.enableLight == 1) {
- color -= roa->deltaLum;
- }
- _screenVGA[offset + 1298] = color;
+ case 2:
+ roa = &_roomObjectAreasTable[_screenLayer2[offset + 1298]];
+ if (wd->y > roa->y1Lum) {
+ if (wd->y <= roa->y2Lum && _gameState.enableLight == 1) {
+ color -= roa->deltaLum;
}
+ _screenVGA[offset + 1298] = color;
}
break;
- case 3: {
- RoomObjectArea *roa = &_roomObjectAreasTable[_screenLayer2[offset + 1293]];
- if (wd->y > roa->y1Lum) {
- if (wd->y <= roa->y2Lum && _gameState.enableLight == 1) {
- color -= roa->deltaLum;
- }
- _screenVGA[offset + 1293] = color;
- }
- color = (fl == 0) ? 196 : 195;
- roa = &_roomObjectAreasTable[_screenLayer2[offset + 1296]];
- if (wd->y > roa->y1Lum) {
- if (wd->y <= roa->y2Lum && _gameState.enableLight == 1) {
- color -= roa->deltaLum;
- }
- _screenVGA[offset + 1296] = color;
+ case 3:
+ roa = &_roomObjectAreasTable[_screenLayer2[offset + 1293]];
+ if (wd->y > roa->y1Lum) {
+ if (wd->y <= roa->y2Lum && _gameState.enableLight == 1) {
+ color -= roa->deltaLum;
}
+ _screenVGA[offset + 1293] = color;
+ }
+ color = (fl == 0) ? 196 : 195;
+ roa = &_roomObjectAreasTable[_screenLayer2[offset + 1296]];
+ if (wd->y > roa->y1Lum) {
+ if (wd->y <= roa->y2Lum && _gameState.enableLight == 1) {
+ color -= roa->deltaLum;
+ }
+ _screenVGA[offset + 1296] = color;
}
break;
- case 4: {
- RoomObjectArea *roa = &_roomObjectAreasTable[_screenLayer2[offset + 1291]];
- if (wd->y > roa->y1Lum) {
- if (wd->y <= roa->y2Lum && _gameState.enableLight == 1) {
- color -= roa->deltaLum;
- }
- _screenVGA[offset + 1291] = color;
+ case 4:
+ roa = &_roomObjectAreasTable[_screenLayer2[offset + 1291]];
+ if (wd->y > roa->y1Lum) {
+ if (wd->y <= roa->y2Lum && _gameState.enableLight == 1) {
+ color -= roa->deltaLum;
}
+ _screenVGA[offset + 1291] = color;
}
break;
}
@@ -1323,10 +1303,10 @@ void IgorEngine::scrollInventory() {
memcpy(_screenVGA + 54400, _inventoryPanelBuffer + (_scrollInventoryStartY - 1) * 320, 9600);
_scrollInventory = false;
} else {
- _gameState.counter[2] = 54420;
- for (_gameState.counter[1] = _scrollInventoryStartY; _gameState.counter[1] < _scrollInventoryStartY + 29; ++_gameState.counter[1]) {
- memcpy(_screenVGA + _gameState.counter[2], _inventoryPanelBuffer + 320 * _gameState.counter[1] - 300, 280);
- _gameState.counter[2] += 320;
+ int offset = 54420;
+ for (int y = _scrollInventoryStartY; y < _scrollInventoryStartY + 29; ++y) {
+ memcpy(_screenVGA + offset, _inventoryPanelBuffer + 320 * y - 300, 280);
+ offset += 320;
}
_scrollInventoryStartY += _scrollInventoryDy;
}
@@ -1598,7 +1578,7 @@ void IgorEngine::handleRoomInput() {
}
void IgorEngine::animateIgorTalking(int frame) {
- if (_currentPart == 850) {
+ if (getPart() == 85) {
PART_85_HELPER_6(frame);
return;
}
@@ -1706,24 +1686,26 @@ int IgorEngine::lookupScale(int xOffset, int yOffset, int h) const {
return offset;
}
-void IgorEngine::moveIgorHelper1(int pos, int frame) {
- debug(kDebugWalk, "moveIgorHelper1 _walkDataCurrentIndex %d pos %d frame %d", _walkDataCurrentIndex, pos, frame);
- uint8 _walkClipSkipX = _walkData[_walkDataCurrentIndex].clipSkipX;
- uint8 _walkHeightScale = _walkData[_walkDataCurrentIndex].scaleHeight;
- int16 _walkClipWidth = _walkData[_walkDataCurrentIndex].clipWidth;
- uint16 _walkScaleWidth = _walkData[_walkDataCurrentIndex].scaleWidth;
- uint8 _walkXPosChanged = _walkData[_walkDataCurrentIndex].xPosChanged;
- int16 _walkDxPos = _walkData[_walkDataCurrentIndex].dxPos + 1;
- uint8 _walkYPosChanged = _walkData[_walkDataCurrentIndex].yPosChanged;
- int16 _walkDyPos = _walkData[_walkDataCurrentIndex].dyPos;
- int16 _walkDataCurrentPosX2 = _walkData[_walkDataCurrentIndex].x;
- int16 _walkDataCurrentPosY2 = _walkData[_walkDataCurrentIndex].y;
-
- uint16 _walkDataDrawOffset = (_walkData[_walkDataCurrentIndex].y - _walkData[_walkDataCurrentIndex].scaleWidth + 1) * 320;
-
- int xPos = _walkWidthScaleTable[_walkData[_walkDataCurrentIndex].scaleHeight - 1] / 2;
- if (_walkData[_walkDataCurrentIndex].x > xPos) {
- _walkDataDrawOffset += _walkData[_walkDataCurrentIndex].x - xPos;
+void IgorEngine::moveIgor(int pos, int frame) {
+ assert(_gameState.enableLight == 1 || _gameState.enableLight == 2);
+ debug(kDebugWalk, "moveIgorHelper _walkDataCurrentIndex %d pos %d frame %d", _walkDataCurrentIndex, pos, frame);
+ WalkData *wd = &_walkData[_walkDataCurrentIndex];
+ uint8 _walkClipSkipX = wd->clipSkipX;
+ uint8 _walkHeightScale = wd->scaleHeight;
+ int16 _walkClipWidth = wd->clipWidth;
+ uint16 _walkScaleWidth = wd->scaleWidth;
+ uint8 _walkXPosChanged = wd->xPosChanged;
+ int16 _walkDxPos = wd->dxPos + 1;
+ uint8 _walkYPosChanged = wd->yPosChanged;
+ int16 _walkDyPos = wd->dyPos;
+ int16 _walkDataCurrentPosX2 = wd->x;
+ int16 _walkDataCurrentPosY2 = wd->y;
+
+ uint16 _walkDataDrawOffset = (wd->y - wd->scaleWidth + 1) * 320;
+
+ int xPos = _walkWidthScaleTable[wd->scaleHeight - 1] / 2;
+ if (wd->x > xPos) {
+ _walkDataDrawOffset += wd->x - xPos;
}
if (_walkXPosChanged != 0) {
_walkDataDrawOffset -= _walkDxPos;
@@ -1765,10 +1747,6 @@ void IgorEngine::moveIgorHelper1(int pos, int frame) {
memcpy(_igorTempFrames + igorBodyScanLine * 50, _screenLayer1 + _walkDataDrawOffset, _walkDxPos);
int xOffset = _walkClipSkipX - 1;
for (int i = 0; i < _walkClipWidth; ++i) {
-/* int index = READ_LE_UINT16(_walkScaleTable + 0x734 + _walkWidthScaleTable[_walkHeightScale - 1] * 2);
- int offset = _walkScaleTable[0x4FC + index + xOffset];
- index = READ_LE_UINT16(_walkScaleTable + 0x6CE + _walkHeightScale * 2);
- offset += _walkScaleTable[index + yOffset] * 30;*/
int offset = lookupScale(xOffset, yOffset, _walkHeightScale);
offset += frame * 1500;
uint8 color = _facingIgorFrames[pos - 1][offset];
@@ -1776,10 +1754,10 @@ void IgorEngine::moveIgorHelper1(int pos, int frame) {
assert(_walkDataDrawOffset + _walkDxPos + i >= 0);
int index = _screenLayer2[_walkDataDrawOffset + _walkDxPos + i];
int yPos = _roomObjectAreasTable[index].y1Lum;
- if (_walkData[_walkDataCurrentIndex].y <= yPos) {
+ if (wd->y <= yPos) {
_igorTempFrames[igorBodyScanLine * 50 + i + _walkDxPos] = _screenLayer1[_walkDataDrawOffset + _walkDxPos + i];
} else {
- if (_gameState.enableLight == 1 && _walkData[_walkDataCurrentIndex].y <= _roomObjectAreasTable[index].y2Lum) {
+ if (_gameState.enableLight == 1 && wd->y <= _roomObjectAreasTable[index].y2Lum) {
color -= _roomObjectAreasTable[index].deltaLum;
}
_igorTempFrames[igorBodyScanLine * 50 + i + _walkDxPos] = color;
@@ -1796,10 +1774,6 @@ void IgorEngine::moveIgorHelper1(int pos, int frame) {
for (int yOffset = 0; yOffset < _walkScaleWidth; ++yOffset) {
int xOffset = _walkClipSkipX - 1;
for (int i = 0; i < _walkClipWidth; ++i) {
-/* int index = READ_LE_UINT16(_walkScaleTable + 0x734 + _walkWidthScaleTable[_walkHeightScale - 1] * 2);
- int offset = _walkScaleTable[0x4FC + index + xOffset];
- index = READ_LE_UINT16(_walkScaleTable + 0x6CE + _walkHeightScale * 2);
- offset += _walkScaleTable[index + yOffset] * 30;*/
int offset = lookupScale(xOffset, yOffset, _walkHeightScale);
offset += frame * 1500;
uint8 color = _facingIgorFrames[pos - 1][offset];
@@ -1807,10 +1781,10 @@ void IgorEngine::moveIgorHelper1(int pos, int frame) {
assert(_walkDataDrawOffset + i >= 0);
int index = _screenLayer2[_walkDataDrawOffset + i];
int yPos = _roomObjectAreasTable[index].y1Lum;
- if (_walkData[_walkDataCurrentIndex].y <= yPos) {
+ if (wd->y <= yPos) {
_igorTempFrames[igorBodyScanLine * 50 + i] = _screenLayer1[_walkDataDrawOffset + i];
} else {
- if (_gameState.enableLight == 1 && _walkData[_walkDataCurrentIndex].y <= _roomObjectAreasTable[index].y2Lum) {
+ if (_gameState.enableLight == 1 && wd->y <= _roomObjectAreasTable[index].y2Lum) {
color -= _roomObjectAreasTable[index].deltaLum;
}
_igorTempFrames[igorBodyScanLine * 50 + i] = color;
@@ -1840,11 +1814,6 @@ void IgorEngine::moveIgorHelper1(int pos, int frame) {
}
}
-void IgorEngine::moveIgor(int pos, int frame) {
- assert(_gameState.enableLight == 1 || _gameState.enableLight == 2);
- moveIgorHelper1(pos, frame);
-}
-
void IgorEngine::buildWalkPathSimple(int srcX, int srcY, int dstX, int dstY) {
debug(kDebugWalk, "IgorEngine::buildWalkPathSimple(%d, %d, %d, %d)", srcX, srcY, dstX, dstY);
if (srcX != dstX || srcY != dstY) {
@@ -2756,13 +2725,13 @@ void IgorEngine::fixWalkPosition(int *x, int *y) {
if (xPos > _roomWalkBounds.x2) {
xPos = _roomWalkBounds.x2;
}
- if (_currentPart == 22) {
+ if (getPart() == 22) {
*x = xPos;
*y = _roomWalkBounds.y1;
return;
}
int yPos = *y;
- if (_currentPart == 13) {
+ if (getPart() == 13) {
if (xPos >= 92 && xPos <= 186 && yPos > 127) {
*x = xPos;
*y = 127;
@@ -2778,7 +2747,7 @@ void IgorEngine::fixWalkPosition(int *x, int *y) {
while (_roomObjectAreasTable[_screenLayer2[yPos * 320 + xPos]].area == 0 && yPos < _roomWalkBounds.y2) {
++yPos;
}
- if (_currentPart == 17) {
+ if (getPart() == 17) {
if (yPos != 143 || _roomObjectAreasTable[_screenLayer2[45760 + xPos]].area != 0) {
*x = xPos;
*y = yPos;
@@ -2814,10 +2783,10 @@ void IgorEngine::handleDialogue(int x, int y, int r, int g, int b) {
_gameState.dialogueChoiceCount = 1;
_dialogueEnded = false;
do {
- if (_currentPart / 10 == 15 && _objectsState[48] == 0) {
+ if (getPart() == 15 && _objectsState[48] == 0) {
_gameState.dialogueData[6] = 0;
}
- if (_currentPart / 10 == 12 && _objectsState[44] == 0) {
+ if (getPart() == 12 && _objectsState[44] == 0) {
_gameState.dialogueData[6] = 1;
}
drawDialogueChoices();
@@ -2832,12 +2801,12 @@ void IgorEngine::handleDialogue(int x, int y, int r, int g, int b) {
dialogueReplyToQuestion(x, y, r, g, b);
int offset = (_dialogueInfo[_dialogueChoiceSelected] - 1) * 6 + (_gameState.dialogueChoiceCount - 1) * 30 + (_gameState.dialogueChoiceStart - 1) * _roomDataOffsets.dlg.matSize;
int code = _gameState.dialogueData[offset + 5];
- if ((code >= 1 && code <= 99) || (_currentPart / 10 == 15 && code == 1)) {
+ if ((code >= 1 && code <= 99) || (getPart() == 15 && code == 1)) {
_gameState.dialogueData[offset] = 0;
- if (_currentPart / 10 == 21 && (code == 60 || code == 70 || code == 80) && _dialogueInfo[0] == 1) {
+ if (getPart() == 21 && (code == 60 || code == 70 || code == 80) && _dialogueInfo[0] == 1) {
_gameState.dialogueData[offset + 2] = 4;
}
- if (_currentPart / 10 == 33 && (code == 21 || code == 22 || code == 23) && _dialogueInfo[0] == 1) {
+ if (getPart() == 33 && (code == 21 || code == 22 || code == 23) && _dialogueInfo[0] == 1) {
_gameState.dialogueData[offset + 2] = 2;
}
}
@@ -2927,7 +2896,7 @@ void IgorEngine::dialogueAskQuestion() {
memset(_screenVGA + 46080, 0, 17920);
int offset = (_dialogueInfo[_dialogueChoiceSelected] - 1) * 6 + (_gameState.dialogueChoiceCount - 1) * 30 + (_gameState.dialogueChoiceStart - 1) * _roomDataOffsets.dlg.matSize;
int num = _gameState.dialogueData[offset + 3] - 1;
- if (_currentPart / 10 == 17) {
+ if (getPart() == 17) {
num = 5;
}
debug(kDebugEngine, "dialogueAskQuestion() num %d offset %d", num, offset);
diff --git a/engines/igor/igor.h b/engines/igor/igor.h
index af2dd1c7c7..018232396a 100644
--- a/engines/igor/igor.h
+++ b/engines/igor/igor.h
@@ -48,6 +48,15 @@ enum {
};
enum {
+ kIdEngDemo100,
+ kIdEngDemo110,
+ kIdEngFloppy,
+ kIdSpaFloppy,
+ kIdEngCD,
+ kIdSpaCD
+};
+
+enum {
kStartupPart = 900,
kTalkColor = 240,
kTalkShadowColor = 241,
@@ -218,7 +227,7 @@ struct WalkData {
struct GameStateData {
uint8 enableLight;
int8 colorLum;
- int32 counter[5];
+ int16 counter[5];
bool igorMoving;
bool dialogueTextRunning;
bool updateLight;
@@ -267,16 +276,12 @@ public:
typedef void (IgorEngine::*UpdateDialogueProc)(int action);
typedef void (IgorEngine::*UpdateRoomBackgroundProc)();
- IgorEngine(OSystem *system);
+ IgorEngine(OSystem *system, int gameVersion);
virtual ~IgorEngine();
virtual int init();
virtual int go();
- void readResourceEntriesTable();
- void restart();
- void waitForTimer(int ticks = -1);
-
void handleOptionsMenu_paintSave();
bool handleOptionsMenu_handleKeyDownSave(int key);
void handleOptionsMenu_paintLoad();
@@ -290,6 +295,10 @@ protected:
bool compareGameTick(int add, int mod) const { return ((_gameTicks + (add & ~7)) % mod) == 0; } // { return ((_gameTicks + add) % mod) == 0; }
bool compareGameTick(int eq) const { return _gameTicks == (eq & ~7); } // { return _gameTicks == eq; }
+ int getPart() const { return _currentPart / 10; }
+ void readResourceTableFile();
+ void restart();
+ void waitForTimer(int ticks = -1);
void copyArea(uint8 *dst, int dstOffset, int dstPitch, const uint8 *src, int srcPitch, int w, int h, bool transparent = false);
int getRandomNumber(int m);
void handleOptionsMenu();
@@ -306,8 +315,7 @@ protected:
void startIgorDialogue();
void waitForEndOfIgorDialogue();
int getObjectFromInventory(int x) const;
- int getSelectedVerb() const;
- const ResourceEntry *findData(int num) const;
+ ResourceEntry findData(int num);
uint8 *loadData(int num, uint8 *dst = 0, int *size = 0);
void decodeMainText(const uint8 *p);
void decodeRoomStrings(const uint8 *p, bool skipObjectNames = false);
@@ -354,7 +362,6 @@ protected:
void handleRoomInventoryScroll();
void handleRoomLight();
int lookupScale(int xOffset, int yOffset, int h) const;
- void moveIgorHelper1(int pos, int frame);
void moveIgor(int pos, int frame);
void buildWalkPathSimple(int srcX, int srcY, int dstX, int dstY);
void getClosestAreaTrianglePoint(int dstArea, int srcArea, int *dstY, int *dstX, int srcY, int srcX);
@@ -382,6 +389,7 @@ protected:
Common::File _ovlFile;
Common::File _sndFile;
+ Common::File _tblFile;
Audio::SoundHandle _sfxHandle;
@@ -403,6 +411,7 @@ protected:
uint32 _nextTimer;
bool _fastMode;
int _language;
+ int _gameVersion;
WalkData _walkData[100];
uint8 _walkCurrentPos;
@@ -461,9 +470,8 @@ protected:
UpdateDialogueProc _updateDialogue;
UpdateRoomBackgroundProc _updateRoomBackground;
int _gameTicks;
- char _saveStateDescriptions[10][100];
- ResourceEntry *_resourceEntriesTable;
int _resourceEntriesCount;
+ int _resourceEntriesOffset;
static const uint8 _dialogueColor[];
static const uint8 _sentenceColorIndex[];
diff --git a/engines/igor/parts/part_13.cpp b/engines/igor/parts/part_13.cpp
index e33cc69918..0aafdcbbec 100644
--- a/engines/igor/parts/part_13.cpp
+++ b/engines/igor/parts/part_13.cpp
@@ -137,15 +137,15 @@ void IgorEngine::PART_13_ACTION_101_103() {
void IgorEngine::PART_13_ACTION_104() {
_walkDataCurrentIndex = 0;
_walkCurrentFrame = 1;
- for (_gameState.counter[1] = 9; _gameState.counter[1] >= 0; --_gameState.counter[1]) {
- if (_gameState.counter[1] == 9) {
+ for (int i = 9; i >= 0; --i) {
+ if (i == 9) {
_walkCurrentFrame = 0;
}
_walkData[0].setPos(189, 143, 3, _walkCurrentFrame);
WalkData::setNextFrame(3, _walkCurrentFrame);
_walkData[0].clipSkipX = 1;
_walkData[0].clipWidth = 13;
- _walkData[0].scaleWidth = 13 + _gameState.counter[1];
+ _walkData[0].scaleWidth = 13 + i;
_walkData[0].xPosChanged = 1;
_walkData[0].dxPos = 0;
_walkData[0].yPosChanged = 1;
diff --git a/engines/igor/parts/part_15.cpp b/engines/igor/parts/part_15.cpp
index 411fc73821..6ad73509d4 100644
--- a/engines/igor/parts/part_15.cpp
+++ b/engines/igor/parts/part_15.cpp
@@ -424,20 +424,20 @@ void IgorEngine::PART_15_HELPER_5() {
void IgorEngine::PART_15_HELPER_6(int frame) {
_roomCursorOn = false;
- for (_gameState.counter[1] = 0; _gameState.counter[1] <= 17; ++_gameState.counter[1]) {
- for (_gameState.counter[2] = 0; _gameState.counter[2] <= 52; ++_gameState.counter[2]) {
- int offset = (_gameState.counter[1] + 23) * 320 + _gameState.counter[2] + 18;
+ for (int i = 0; i <= 17; ++i) {
+ for (int j = 0; j <= 52; ++j) {
+ int offset = (i + 23) * 320 + j + 18;
uint8 color = _screenVGA[offset];
if (color < 0xF0 || color > 0xF1) {
- color = _animFramesBuffer[0x4B8C + frame * 954 + _gameState.counter[1] * 53 + _gameState.counter[2]];
+ color = _animFramesBuffer[0x4B8C + frame * 954 + i * 53 + j];
}
- _screenTempLayer[_gameState.counter[1] * 100 + _gameState.counter[2]] = color;
+ _screenTempLayer[i * 100 + j] = color;
}
}
int offset = 7378;
- for (_gameState.counter[1] = 0; _gameState.counter[1] <= 17; ++_gameState.counter[1]) {
- memcpy(_screenVGA + _gameState.counter[1] * 320 + offset, _screenTempLayer + _gameState.counter[1] * 100, 53);
- memcpy(_screenLayer1 + _gameState.counter[1] * 320 + offset, _animFramesBuffer + 0x4B8C + frame * 954 + _gameState.counter[1] * 53, 53);
+ for (int i = 0; i <= 17; ++i) {
+ memcpy(_screenVGA + i * 320 + offset, _screenTempLayer + i * 100, 53);
+ memcpy(_screenLayer1 + i * 320 + offset, _animFramesBuffer + 0x4B8C + frame * 954 + i * 53, 53);
}
if (_gameState.dialogueTextRunning) {
memcpy(_screenTextLayer + 23040, _screenLayer1 + _dialogueDirtyRectY, _dialogueDirtyRectSize);
diff --git a/engines/igor/parts/part_36.cpp b/engines/igor/parts/part_36.cpp
index 9510ac6ae5..1973bf9101 100644
--- a/engines/igor/parts/part_36.cpp
+++ b/engines/igor/parts/part_36.cpp
@@ -77,28 +77,28 @@ void IgorEngine::PART_36_EXEC_ACTION(int action) {
}
void IgorEngine::PART_36_ACTION_102() {
- for (_gameState.counter[0] = 1; _gameState.counter[0] >= 0; --_gameState.counter[0]) {
- for (_gameState.counter[1] = 0; _gameState.counter[1] <= 48; ++_gameState.counter[1]) {
- for (_gameState.counter[2] = 0; _gameState.counter[2] <= 33; ++_gameState.counter[2]) {
- uint8 color = _animFramesBuffer[14 + _gameState.counter[0] * 1666 + _gameState.counter[1] * 34 + _gameState.counter[2]];
- int offset = (_gameState.counter[1] + 74) * 320 + _gameState.counter[2] + 70;
+ for (int i = 1; i >= 0; --i) {
+ for (int j = 0; j <= 48; ++j) {
+ for (int k = 0; k <= 33; ++k) {
+ uint8 color = _animFramesBuffer[14 + i * 1666 + j * 34 + k];
+ int offset = (j + 74) * 320 + k + 70;
if (color < 192 || color > 207) {
- _screenTempLayer[100 * _gameState.counter[1] + _gameState.counter[2]] = color;
+ _screenTempLayer[100 * j + k] = color;
continue;
}
RoomObjectArea *roa = &_roomObjectAreasTable[_screenLayer2[offset]];
if (roa->y1Lum > 0) {
- _screenTempLayer[100 * _gameState.counter[1] + _gameState.counter[2]] = _screenLayer1[offset];
+ _screenTempLayer[100 * j + k] = _screenLayer1[offset];
} else {
if (roa->y2Lum > 0) {
color -= roa->deltaLum;
}
- _screenTempLayer[100 * _gameState.counter[1] + _gameState.counter[2]] = color;
+ _screenTempLayer[100 * j + k] = color;
}
}
}
- for (_gameState.counter[1] = 0; _gameState.counter[1] <= 48; ++_gameState.counter[1]) {
- memcpy(_screenVGA + _gameState.counter[1] * 320 + 23750, _screenTempLayer + _gameState.counter[1] * 100, 34);
+ for (int j = 0; j <= 48; ++j) {
+ memcpy(_screenVGA + j * 320 + 23750, _screenTempLayer + j * 100, 34);
}
waitForTimer(45);
}
diff --git a/engines/igor/parts/part_85.cpp b/engines/igor/parts/part_85.cpp
index 495ffbd7a7..26c6129e5c 100644
--- a/engines/igor/parts/part_85.cpp
+++ b/engines/igor/parts/part_85.cpp
@@ -181,7 +181,7 @@ void IgorEngine::PART_85() {
if (_inputVars[kInputEscape]) goto PART_85_EXIT;
PART_85_HELPER_1(0x74CA, 0xA6C4, 1, 6, 32);
if (_inputVars[kInputEscape]) goto PART_85_EXIT;
- for (_gameState.counter[4] = 0; _gameState.counter[4] != 200; ++_gameState.counter[4]) {
+ for (int i = 0; i != 200; ++i) {
PART_85_UPDATE_ROOM_BACKGROUND();
if (_inputVars[kInputEscape]) goto PART_85_EXIT;
waitForTimer();