diff options
author | stevenhoefel | 2017-01-16 21:08:04 +1100 |
---|---|---|
committer | stevenhoefel | 2017-01-16 21:08:04 +1100 |
commit | 863827321cf43e5a65df7d7fd129ea70c3830f09 (patch) | |
tree | b68fd76caf3dc65437f1b71569f2101f1b76d361 /engines | |
parent | 5fbb4fc6a02855492d8e0ebc89911827c6517d84 (diff) | |
download | scummvm-rg350-863827321cf43e5a65df7d7fd129ea70c3830f09.tar.gz scummvm-rg350-863827321cf43e5a65df7d7fd129ea70c3830f09.tar.bz2 scummvm-rg350-863827321cf43e5a65df7d7fd129ea70c3830f09.zip |
DIRECTOR: Implement function 'marker'.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/director/lingo/lingo-builtins.cpp | 5 | ||||
-rw-r--r-- | engines/director/lingo/lingo-funcs.cpp | 23 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 1 | ||||
-rw-r--r-- | engines/director/score.cpp | 110 | ||||
-rw-r--r-- | engines/director/score.h | 10 |
5 files changed, 95 insertions, 54 deletions
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<uint16> clutList = _movieArchive->getResourceIDList(MKTAG('C','L','U','T')); + Common::Array<uint16> 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<uint16> vwci = _movieArchive->getResourceIDList(MKTAG('V','W','C','I')); + Common::Array<uint16> vwci = _movieArchive->getResourceIDList(MKTAG('V', 'W', 'C', 'I')); if (vwci.size() > 0) { for (Common::Array<uint16>::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<uint16> cast = _movieArchive->getResourceIDList(MKTAG('C','A','S','t')); + Common::Array<uint16> cast = _movieArchive->getResourceIDList(MKTAG('C', 'A', 'S', 't')); if (cast.size() > 0) { for (Common::Array<uint16>::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<Label *>::iterator i; @@ -730,49 +730,71 @@ void Score::gotoloop() { } } -void Score::gotonext() { +int Score::getCurrentLabelNumber() { Common::SortedArray<Label *>::iterator i; + int frame = 0; + for (i = _labels->begin(); i != _labels->end(); ++i) { - if ((*i)->name == _currentLabel) { + if ((*i)->number <= _currentFrame) + frame = (*i)->number; + } + + return frame; +} + +void Score::gotoNext() { + //we can just try to use the current frame and get the next label + _currentFrame = getNextLabelNumber(_currentFrame); +} + +void Score::gotoPrevious() { + //we actually need the frame of the label prior to the most recent label. + _currentFrame = getPreviousLabelNumber(getCurrentLabelNumber()); +} + +int Score::getNextLabelNumber(int referenceFrame) { + if (_labels == NULL || _labels->size() == 0) + return 0; + + Common::SortedArray<Label *>::iterator i; + + for (i = _labels->begin(); i != _labels->end(); ++i) { + if ((*i)->number >= referenceFrame) { if (i != _labels->end()) { // return to the first marker to to the right ++i; - _currentFrame = (*i)->number; - return; + return (*i)->number; } else { // if no markers are to the right of the playback head, // the playback head goes to the first marker to the left - _currentFrame = (*i)->number; - return; + return (*i)->number; } } } + // If there are not markers to the left, // the playback head goes to frame 1, (Director frame array start from 1, engine from 0) - _currentFrame = 0; + return 0; } -void Score::gotoprevious() { +int Score::getPreviousLabelNumber(int referenceFrame) { + if (_labels == NULL || _labels->size() == 0) + return 0; + // One label - if (_labels->begin() == _labels->end()) { - _currentFrame = (*_labels->begin())->number; - return; - } + if (_labels->begin() == _labels->end()) + return (*_labels->begin())->number; Common::SortedArray<Label *>::iterator previous = _labels->begin(); - Common::SortedArray<Label *>::iterator i = previous++; + Common::SortedArray<Label *>::iterator i; - for (i = _labels->begin(); i != _labels->end(); ++i, ++previous) { - if ((*i)->name == _currentLabel) { - _currentFrame = (*previous)->number; - return; - } else { - _currentFrame = (*i)->number; - return; - } + for (i = (previous + 1); i != _labels->end(); ++i, ++previous) { + if ((*i)->number >= referenceFrame) + return (*previous)->number; } - _currentFrame = 0; + + return 0; } Common::String Score::getString(Common::String str) { diff --git a/engines/director/score.h b/engines/director/score.h index 9b92e48f93..a53c13fc4d 100644 --- a/engines/director/score.h +++ b/engines/director/score.h @@ -61,9 +61,9 @@ public: static int compareLabels(const void *a, const void *b); void loadArchive(); void setStartToLabel(Common::String label); - void gotoloop(); - void gotonext(); - void gotoprevious(); + void gotoLoop(); + void gotoNext(); + void gotoPrevious(); void startLoop(); void processEvents(); Archive *getArchive() const { return _movieArchive; }; @@ -77,6 +77,10 @@ public: void setSpriteCasts(); Graphics::ManagedSurface *getSurface() { return _surface; } + int getPreviousLabelNumber(int referenceFrame); + int getCurrentLabelNumber(); + int getNextLabelNumber(int referenceFrame); + private: void update(); void readVersion(uint32 rid); |