Unified
Split
Showing
with
54 additions
and 15 deletions.
- +8 −4 engines/director/frame.cpp
- +4 −1 engines/director/lingo/lingo.cpp
- +9 −5 engines/director/resource.cpp
- +32 −4 engines/director/score.cpp
- +1 −1 engines/director/util.cpp
| @@ -222,10 +222,14 @@ void Frame::readChannels(Common::ReadStreamEndian *stream) { | ||
| sprite._unk3 = stream->readUint32(); | ||
| } | ||
|
|
||
| debugC(kDebugLoading, 8, "%03d(%d)[%x,%x,%04x,%d/%d/%d/%d/%d] script:%d", | ||
| sprite._castId, sprite._enabled, sprite._x1, sprite._x2, sprite._flags, | ||
| sprite._startPoint.x, sprite._startPoint.y, sprite._width, sprite._height, | ||
| sprite._lineSize, sprite._scriptId); | ||
| if (sprite._castId) { | ||
| debugC(kDebugLoading, 4, "CH: %-3d castId: %03d(%s) (e:%d) [%x,%x, flags:%04x, %dx%d@%d,%d linesize: %d] script: %d", | ||
| i + 1, sprite._castId, numToCastNum(sprite._castId), sprite._enabled, sprite._x1, sprite._x2, sprite._flags, | ||
| sprite._width, sprite._height, sprite._startPoint.x, sprite._startPoint.y, | ||
| sprite._lineSize, sprite._scriptId); | ||
| } else { | ||
| debugC(kDebugLoading, 4, "CH: %-3d castId: 000", i + 1); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @@ -299,16 +299,19 @@ void Lingo::processEvent(LEvent event, ScriptType st, int entityId) { | ||
| if (entityId < 0) | ||
| return; | ||
|
|
||
| debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d)", _eventHandlerTypes[event], scriptType2str(st), entityId); | ||
| debugC(9, kDebugEvents, "Lingo::processEvent(%s, %s, %d)", _eventHandlerTypes[event], scriptType2str(st), entityId); | ||
|
|
||
| _currentEntityId = entityId; | ||
|
|
||
| if (!_eventHandlerTypes.contains(event)) | ||
| error("processEvent: Unknown event %d for entity %d", event, entityId); | ||
|
|
||
| if (_handlers.contains(ENTITY_INDEX(event, entityId))) { | ||
| debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d), _eventHandler", _eventHandlerTypes[event], scriptType2str(st), entityId); | ||
| call(_eventHandlerTypes[event], 0); // D4+ Events | ||
| } else if (_scripts[st].contains(entityId)) { | ||
| debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d), script", _eventHandlerTypes[event], scriptType2str(st), entityId); | ||
|
|
||
| executeScript(st, entityId); // D3 list of scripts. | ||
| } else { | ||
| debugC(3, kDebugLingoExec, "STUB: processEvent(%s) for %d", _eventHandlerTypes[event], entityId); | ||
| @@ -200,7 +200,7 @@ void DirectorEngine::loadMac(const Common::String movie) { | ||
| void DirectorEngine::loadSharedCastsFrom(Common::String filename) { | ||
| Archive *shardcst = createArchive(); | ||
|
|
||
| debug(0, "Loading Shared cast '%s'", filename.c_str()); | ||
| debug(0, "****** Loading Shared cast '%s'", filename.c_str()); | ||
|
|
||
| _sharedDIB = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>; | ||
| _sharedSTXT = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>; | ||
| @@ -229,12 +229,16 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) { | ||
|
|
||
| Common::Array<uint16> cast = shardcst->getResourceIDList(MKTAG('C','A','S','t')); | ||
| if (cast.size() > 0) { | ||
| debug(0, "****** Loading %d CASt resources", cast.size()); | ||
|
|
||
| for (Common::Array<uint16>::iterator iterator = cast.begin(); iterator != cast.end(); ++iterator) | ||
| _sharedScore->loadCastData(*shardcst->getResource(MKTAG('C','A','S','t'), *iterator), *iterator, NULL); | ||
| } | ||
|
|
||
| Common::Array<uint16> vwci = shardcst->getResourceIDList(MKTAG('V', 'W', 'C', 'I')); | ||
| if (vwci.size() > 0) { | ||
| debug(0, "****** Loading %d CastInfo resources", vwci.size()); | ||
|
|
||
| for (Common::Array<uint16>::iterator iterator = vwci.begin(); iterator != vwci.end(); ++iterator) | ||
| _sharedScore->loadCastInfo(*shardcst->getResource(MKTAG('V', 'W', 'C', 'I'), *iterator), *iterator); | ||
| } | ||
| @@ -243,7 +247,7 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) { | ||
|
|
||
| Common::Array<uint16> dib = shardcst->getResourceIDList(MKTAG('D','I','B',' ')); | ||
| if (dib.size() != 0) { | ||
| debugC(3, kDebugLoading, "Loading %d DIBs", dib.size()); | ||
| debugC(3, kDebugLoading, "****** Loading %d DIBs", dib.size()); | ||
|
|
||
| for (Common::Array<uint16>::iterator iterator = dib.begin(); iterator != dib.end(); ++iterator) { | ||
| debugC(3, kDebugLoading, "Shared DIB %d", *iterator); | ||
| @@ -253,7 +257,7 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) { | ||
|
|
||
| Common::Array<uint16> stxt = shardcst->getResourceIDList(MKTAG('S','T','X','T')); | ||
| if (stxt.size() != 0) { | ||
| debugC(3, kDebugLoading, "Loading %d STXTs", stxt.size()); | ||
| debugC(3, kDebugLoading, "****** Loading %d STXTs", stxt.size()); | ||
|
|
||
| for (Common::Array<uint16>::iterator iterator = stxt.begin(); iterator != stxt.end(); ++iterator) { | ||
| debugC(3, kDebugLoading, "Shared STXT %d", *iterator); | ||
| @@ -263,7 +267,7 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) { | ||
|
|
||
| Common::Array<uint16> bmp = shardcst->getResourceIDList(MKTAG('B','I','T','D')); | ||
| if (bmp.size() != 0) { | ||
| debugC(3, kDebugLoading, "Loading %d BITDs", bmp.size()); | ||
| debugC(3, kDebugLoading, "****** Loading %d BITDs", bmp.size()); | ||
| for (Common::Array<uint16>::iterator iterator = bmp.begin(); iterator != bmp.end(); ++iterator) { | ||
| debugC(3, kDebugLoading, "Shared BITD %d (%s)", *iterator, numToCastNum(*iterator - 1024)); | ||
| _sharedBMP->setVal(*iterator, shardcst->getResource(MKTAG('B','I','T','D'), *iterator)); | ||
| @@ -272,7 +276,7 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) { | ||
|
|
||
| Common::Array<uint16> sound = shardcst->getResourceIDList(MKTAG('S','N','D',' ')); | ||
| if (sound.size() != 0) { | ||
| debugC(3, kDebugLoading, "Loading %d SNDs", sound.size()); | ||
| debugC(3, kDebugLoading, "****** Loading %d SNDs", sound.size()); | ||
| for (Common::Array<uint16>::iterator iterator = sound.begin(); iterator != sound.end(); ++iterator) { | ||
| debugC(3, kDebugLoading, "Shared SND %d", *iterator); | ||
| _sharedSound->setVal(*iterator, shardcst->getResource(MKTAG('S','N','D',' '), *iterator)); | ||
| @@ -120,6 +120,7 @@ void Score::loadArchive() { | ||
| } else { | ||
| Common::SeekableSubReadStreamEndian *pal = _movieArchive->getResource(MKTAG('C', 'L', 'U', 'T'), clutList[0]); | ||
|
|
||
| debugC(2, kDebugLoading, "****** Loading Palette"); | ||
| loadPalette(*pal); | ||
| g_system->getPaletteManager()->setPalette(_vm->getPalette(), 0, _vm->getPaletteColorCount()); | ||
| } | ||
| @@ -155,12 +156,16 @@ void Score::loadArchive() { | ||
|
|
||
| Common::Array<uint16> vwci = _movieArchive->getResourceIDList(MKTAG('V', 'W', 'C', 'I')); | ||
| if (vwci.size() > 0) { | ||
| debugC(2, kDebugLoading, "****** Loading %d CastInfos", vwci.size()); | ||
|
|
||
| for (Common::Array<uint16>::iterator iterator = vwci.begin(); iterator != vwci.end(); ++iterator) | ||
| loadCastInfo(*_movieArchive->getResource(MKTAG('V', 'W', 'C', 'I'), *iterator), *iterator); | ||
| } | ||
|
|
||
| Common::Array<uint16> cast = _movieArchive->getResourceIDList(MKTAG('C', 'A', 'S', 't')); | ||
| if (cast.size() > 0) { | ||
| debugC(2, kDebugLoading, "****** Loading %d CASt resources", cast.size()); | ||
|
|
||
| for (Common::Array<uint16>::iterator iterator = cast.begin(); iterator != cast.end(); ++iterator) { | ||
| Common::SeekableSubReadStreamEndian *stream = _movieArchive->getResource(MKTAG('C', 'A', 'S', 't'), *iterator); | ||
| Resource res = _movieArchive->getResourceDetail(MKTAG('C', 'A', 'S', 't'), *iterator); | ||
| @@ -175,6 +180,8 @@ void Score::loadArchive() { | ||
| if (_vm->getVersion() <= 3) { | ||
| Common::Array<uint16> stxt = _movieArchive->getResourceIDList(MKTAG('S','T','X','T')); | ||
| if (stxt.size() > 0) { | ||
| debugC(2, kDebugLoading, "****** Loading %d STXT resources", stxt.size()); | ||
|
|
||
| for (Common::Array<uint16>::iterator iterator = stxt.begin(); iterator != stxt.end(); ++iterator) { | ||
| loadScriptText(*_movieArchive->getResource(MKTAG('S','T','X','T'), *iterator)); | ||
| } | ||
| @@ -183,6 +190,8 @@ void Score::loadArchive() { | ||
| } | ||
|
|
||
| void Score::loadSpriteImages(bool isSharedCast) { | ||
| debugC(1, kDebugLoading, "****** Preloading sprite images"); | ||
|
|
||
| Common::HashMap<int, BitmapCast *>::iterator bc; | ||
| for (bc = _loadedBitmaps->begin(); bc != _loadedBitmaps->end(); ++bc) { | ||
| if (bc->_value) { | ||
| @@ -277,6 +286,8 @@ void Score::loadPalette(Common::SeekableSubReadStreamEndian &stream) { | ||
| } | ||
|
|
||
| void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) { | ||
| debugC(1, kDebugLoading, "****** Loading frames"); | ||
|
|
||
| uint32 size = stream.readUint32(); | ||
| size -= 4; | ||
|
|
||
| @@ -334,7 +345,7 @@ void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) { | ||
| //Common::hexdump(channelData, ARRAYSIZE(channelData)); | ||
| frame->readChannels(str); | ||
|
|
||
| debugC(3, kDebugLoading, "Frame %d actionId: %d", _frames.size() + 1, frame->_actionId); | ||
| debugC(3, kDebugLoading, "Frame %d actionId: %d", _frames.size(), frame->_actionId); | ||
|
|
||
| delete str; | ||
|
|
||
| @@ -343,6 +354,8 @@ void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) { | ||
| } | ||
|
|
||
| void Score::loadConfig(Common::SeekableSubReadStreamEndian &stream) { | ||
| debugC(1, kDebugLoading, "****** Loading Config"); | ||
|
|
||
| /*uint16 unk1 = */ stream.readUint16(); | ||
| /*ver1 = */ stream.readUint16(); | ||
| _movieRect = Score::readRect(stream); | ||
| @@ -362,7 +375,7 @@ void Score::readVersion(uint32 rid) { | ||
| } | ||
|
|
||
| void Score::loadCastDataVWCR(Common::SeekableSubReadStreamEndian &stream) { | ||
| debugC(1, kDebugLoading, "Score::loadCastDataVWCR(). start: %d, end: %d", _castArrayStart, _castArrayEnd); | ||
| debugC(1, kDebugLoading, "****** Score::loadCastDataVWCR(). start: %d, end: %d", _castArrayStart, _castArrayEnd); | ||
|
|
||
| for (uint16 id = _castArrayStart; id <= _castArrayEnd; id++) { | ||
| byte size = stream.readByte(); | ||
| @@ -376,18 +389,22 @@ void Score::loadCastDataVWCR(Common::SeekableSubReadStreamEndian &stream) { | ||
|
|
||
| switch (castType) { | ||
| case kCastBitmap: | ||
| debugC(3, kDebugLoading, "CastTypes id: %d BitmapCast", id); | ||
| _loadedBitmaps->setVal(id, new BitmapCast(stream)); | ||
| _castTypes[id] = kCastBitmap; | ||
| break; | ||
| case kCastText: | ||
| debugC(3, kDebugLoading, "CastTypes id: %d TextCast", id); | ||
| _loadedText->setVal(id, new TextCast(stream)); | ||
| _castTypes[id] = kCastText; | ||
| break; | ||
| case kCastShape: | ||
| debugC(3, kDebugLoading, "CastTypes id: %d ShapeCast", id); | ||
| _loadedShapes->setVal(id, new ShapeCast(stream)); | ||
| _castTypes[id] = kCastShape; | ||
| break; | ||
| case kCastButton: | ||
| debugC(3, kDebugLoading, "CastTypes id: %d ButtonCast", id); | ||
| _loadedButtons->setVal(id, new ButtonCast(stream)); | ||
| _castTypes[id] = kCastButton; | ||
| break; | ||
| @@ -638,6 +655,7 @@ void Score::loadLabels(Common::SeekableSubReadStreamEndian &stream) { | ||
|
|
||
| Common::SortedArray<Label *>::iterator j; | ||
|
|
||
| debugC(2, kDebugLoading, "****** Loading labels"); | ||
| for (j = _labels->begin(); j != _labels->end(); ++j) { | ||
| debugC(2, kDebugLoading, "Frame %d, Label %s", (*j)->number, (*j)->name.c_str()); | ||
| } | ||
| @@ -648,6 +666,8 @@ int Score::compareLabels(const void *a, const void *b) { | ||
| } | ||
|
|
||
| void Score::loadActions(Common::SeekableSubReadStreamEndian &stream) { | ||
| debugC(2, kDebugLoading, "****** Loading Actions"); | ||
|
|
||
| uint16 count = stream.readUint16() + 1; | ||
| uint16 offset = count * 4 + 2; | ||
|
|
||
| @@ -672,7 +692,7 @@ void Score::loadActions(Common::SeekableSubReadStreamEndian &stream) { | ||
| _actions[i + 1] += ch; | ||
| } | ||
|
|
||
| debugC(3, kDebugLoading, "id: %d nextId: %d subId: %d, code: %s", id, nextId, subId, _actions[id].c_str()); | ||
| debugC(3, kDebugLoading, "Action id: %d nextId: %d subId: %d, code: %s", id, nextId, subId, _actions[id].c_str()); | ||
|
|
||
| stream.seek(streamPos); | ||
|
|
||
| @@ -935,6 +955,8 @@ Common::String Score::getString(Common::String str) { | ||
| } | ||
|
|
||
| void Score::loadFileInfo(Common::SeekableSubReadStreamEndian &stream) { | ||
| debugC(2, kDebugLoading, "****** Loading FileInfo"); | ||
|
|
||
| Common::Array<Common::String> fileInfoStrings = loadStrings(stream, _flags); | ||
| _script = fileInfoStrings[0]; | ||
|
|
||
| @@ -964,6 +986,8 @@ Common::Array<Common::String> Score::loadStrings(Common::SeekableSubReadStreamEn | ||
|
|
||
| uint16 count = stream.readUint16() + 1; | ||
|
|
||
| debugC(3, kDebugLoading, "Strings: %d entries", count); | ||
|
|
||
| uint32 *entries = (uint32 *)calloc(count, sizeof(uint32)); | ||
|
|
||
| for (uint i = 0; i < count; i++) | ||
| @@ -982,6 +1006,8 @@ Common::Array<Common::String> Score::loadStrings(Common::SeekableSubReadStreamEn | ||
| entryString += data[j]; | ||
|
|
||
| strings.push_back(entryString); | ||
|
|
||
| debugC(6, kDebugLoading, "String %d:\n%s\n", i, entryString.c_str()); | ||
| } | ||
|
|
||
| free(data); | ||
| @@ -994,6 +1020,8 @@ void Score::loadFontMap(Common::SeekableSubReadStreamEndian &stream) { | ||
| if (stream.size() == 0) | ||
| return; | ||
|
|
||
| debugC(2, kDebugLoading, "****** Loading FontMap"); | ||
|
|
||
| uint16 count = stream.readUint16(); | ||
| uint32 offset = (count * 2) + 2; | ||
| uint16 currentRawPosition = offset; | ||
| @@ -1014,7 +1042,7 @@ void Score::loadFontMap(Common::SeekableSubReadStreamEndian &stream) { | ||
| _fontMap[id] = font; | ||
| _vm->_wm->_fontMan->registerFontMapping(id, font); | ||
|
|
||
| debug(3, "Fontmap. ID %d Font %s", id, font.c_str()); | ||
| debugC(3, kDebugLoading, "Fontmap. ID %d Font %s", id, font.c_str()); | ||
| currentRawPosition = stream.pos(); | ||
| stream.seek(positionInfo); | ||
| } | ||
| @@ -48,7 +48,7 @@ char *numToCastNum(int num) { | ||
| res[3] = '\0'; | ||
| num--; | ||
|
|
||
| if (num > 0 && num <= 512) { | ||
| if (num >= 0 && num < 512) { | ||
| int c = num / 64; | ||
| res[0] = 'A' + c; | ||
| num -= 64 * c; | ||