From 863827321cf43e5a65df7d7fd129ea70c3830f09 Mon Sep 17 00:00:00 2001 From: stevenhoefel Date: Mon, 16 Jan 2017 21:08:04 +1100 Subject: DIRECTOR: Implement function 'marker'. --- engines/director/lingo/lingo-builtins.cpp | 5 +- engines/director/lingo/lingo-funcs.cpp | 23 +++++-- engines/director/lingo/lingo.h | 1 + engines/director/score.cpp | 110 ++++++++++++++++++------------ engines/director/score.h | 10 ++- 5 files changed, 95 insertions(+), 54 deletions(-) (limited to 'engines') diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp index 4d3b7ddf5b..cf044f2072 100644 --- a/engines/director/lingo/lingo-builtins.cpp +++ b/engines/director/lingo/lingo-builtins.cpp @@ -905,9 +905,8 @@ void Lingo::b_label(int nargs) { void Lingo::b_marker(int nargs) { Datum d = g_lingo->pop(); d.toInt(); - warning("STUB: b_marker(%d)", d.u.i); - - g_lingo->push(Datum(0)); + int marker = g_lingo->func_marker(d.u.i); + g_lingo->push(marker); } void Lingo::b_moveableSprite(int nargs) { diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp index 70580b10be..140549be8b 100644 --- a/engines/director/lingo/lingo-funcs.cpp +++ b/engines/director/lingo/lingo-funcs.cpp @@ -212,21 +212,21 @@ void Lingo::func_gotoloop() { if (!_vm->_currentScore) return; - _vm->_currentScore->gotoloop(); + _vm->_currentScore->gotoLoop(); } void Lingo::func_gotonext() { if (!_vm->_currentScore) return; - _vm->_currentScore->gotonext(); + _vm->_currentScore->gotoNext(); } - + void Lingo::func_gotoprevious() { if (!_vm->_currentScore) return; - _vm->_currentScore->gotoprevious(); + _vm->_currentScore->gotoPrevious(); } void Lingo::func_cursor(int c) { @@ -265,4 +265,19 @@ void Lingo::func_beep(int repeats) { _vm->getSoundManager()->systemBeep(); } +int Lingo::func_marker(int m) { + int labelNumber = _vm->getCurrentScore()->getCurrentLabelNumber(); + if (m != 0) { + if (m < 0) { + for (int marker = 0; marker > m; marker--) + labelNumber = _vm->getCurrentScore()->getPreviousLabelNumber(labelNumber); + } else { + for (int marker = 0; marker < m; marker++) + labelNumber = _vm->getCurrentScore()->getNextLabelNumber(labelNumber); + } + } + + return labelNumber; +} + } diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index a739ee77e7..8e033b181d 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -460,6 +460,7 @@ public: void func_gotonext(); void func_gotoprevious(); void func_cursor(int c); + int func_marker(int m); public: void setTheEntity(int entity, Datum &id, int field, Datum &d); diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 979d29dba2..d8c21d6637 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -157,19 +157,19 @@ Score::Score(DirectorEngine *vm, Archive *archive) { _stopPlay = false; _stageColor = 0; - if (archive->hasResource(MKTAG('M','C','N','M'), 0)) { - _macName = archive->getName(MKTAG('M','C','N','M'), 0).c_str(); + if (archive->hasResource(MKTAG('M', 'C', 'N', 'M'), 0)) { + _macName = archive->getName(MKTAG('M', 'C', 'N', 'M'), 0).c_str(); } else { _macName = archive->getFileName(); } - if (archive->hasResource(MKTAG('V','W','L','B'), 1024)) { - loadLabels(*archive->getResource(MKTAG('V','W','L','B'), 1024)); + if (archive->hasResource(MKTAG('V', 'W', 'L', 'B'), 1024)) { + loadLabels(*archive->getResource(MKTAG('V', 'W', 'L', 'B'), 1024)); } } void Score::loadArchive() { - Common::Array clutList = _movieArchive->getResourceIDList(MKTAG('C','L','U','T')); + Common::Array clutList = _movieArchive->getResourceIDList(MKTAG('C', 'L', 'U', 'T')); if (clutList.size() > 1) warning("More than one palette was found (%d)", clutList.size()); @@ -185,36 +185,36 @@ void Score::loadArchive() { g_system->getPaletteManager()->setPalette(_vm->getPalette(), 0, _vm->getPaletteColorCount()); } - assert(_movieArchive->hasResource(MKTAG('V','W','S','C'), 1024)); - assert(_movieArchive->hasResource(MKTAG('V','W','C','F'), 1024)); + assert(_movieArchive->hasResource(MKTAG('V', 'W', 'S', 'C'), 1024)); + assert(_movieArchive->hasResource(MKTAG('V', 'W', 'C', 'F'), 1024)); - loadFrames(*_movieArchive->getResource(MKTAG('V','W','S','C'), 1024)); - loadConfig(*_movieArchive->getResource(MKTAG('V','W','C','F'), 1024)); + loadFrames(*_movieArchive->getResource(MKTAG('V', 'W', 'S', 'C'), 1024)); + loadConfig(*_movieArchive->getResource(MKTAG('V', 'W', 'C', 'F'), 1024)); if (_vm->getVersion() < 4) { - assert(_movieArchive->hasResource(MKTAG('V','W','C','R'), 1024)); - loadCastDataVWCR(*_movieArchive->getResource(MKTAG('V','W','C','R'), 1024)); + assert(_movieArchive->hasResource(MKTAG('V', 'W', 'C', 'R'), 1024)); + loadCastDataVWCR(*_movieArchive->getResource(MKTAG('V', 'W', 'C', 'R'), 1024)); } - if (_movieArchive->hasResource(MKTAG('V','W','A','C'), 1024)) { - loadActions(*_movieArchive->getResource(MKTAG('V','W','A','C'), 1024)); + if (_movieArchive->hasResource(MKTAG('V', 'W', 'A', 'C'), 1024)) { + loadActions(*_movieArchive->getResource(MKTAG('V', 'W', 'A', 'C'), 1024)); } - if (_movieArchive->hasResource(MKTAG('V','W','F','I'), 1024)) { - loadFileInfo(*_movieArchive->getResource(MKTAG('V','W','F','I'), 1024)); + if (_movieArchive->hasResource(MKTAG('V', 'W', 'F', 'I'), 1024)) { + loadFileInfo(*_movieArchive->getResource(MKTAG('V', 'W', 'F', 'I'), 1024)); } - if (_movieArchive->hasResource(MKTAG('V','W','F','M'), 1024)) { - loadFontMap(*_movieArchive->getResource(MKTAG('V','W','F','M'), 1024)); + if (_movieArchive->hasResource(MKTAG('V', 'W', 'F', 'M'), 1024)) { + loadFontMap(*_movieArchive->getResource(MKTAG('V', 'W', 'F', 'M'), 1024)); } - Common::Array vwci = _movieArchive->getResourceIDList(MKTAG('V','W','C','I')); + Common::Array vwci = _movieArchive->getResourceIDList(MKTAG('V', 'W', 'C', 'I')); if (vwci.size() > 0) { for (Common::Array::iterator iterator = vwci.begin(); iterator != vwci.end(); ++iterator) - loadCastInfo(*_movieArchive->getResource(MKTAG('V','W','C','I'), *iterator), *iterator); + loadCastInfo(*_movieArchive->getResource(MKTAG('V', 'W', 'C', 'I'), *iterator), *iterator); } - Common::Array cast = _movieArchive->getResourceIDList(MKTAG('C','A','S','t')); + Common::Array cast = _movieArchive->getResourceIDList(MKTAG('C', 'A', 'S', 't')); if (cast.size() > 0) { for (Common::Array::iterator iterator = cast.begin(); iterator != cast.end(); ++iterator) { Common::SeekableSubReadStreamEndian *stream = _movieArchive->getResource(MKTAG('C', 'A', 'S', 't'), *iterator); @@ -444,7 +444,7 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id, } debugC(3, kDebugLoading, "CASt: id: %d type: %x size1: %d size2: %d (%x) size3: %d unk1: %d unk2: %d unk3: %d", - id, castType, size1, size2, size2, size3, unk1, unk2, unk3); + id, castType, size1, size2, size2, size3, unk1, unk2, unk3); byte *data = (byte *)calloc(size1 + 16, 1); // 16 is for bounding rects stream.read(data, size1 + 16); @@ -717,7 +717,7 @@ void Score::loadCastInfo(Common::SeekableSubReadStreamEndian &stream, uint16 id) _castsInfo[id] = ci; } -void Score::gotoloop() { +void Score::gotoLoop() { // This command has the playback head contonuously return to the first marker to to the left and then loop back. // If no marker are to the left of the playback head, the playback head continues to the right. Common::SortedArray