DIRECTOR: Refactor tempo, remove scoreCachedTempo

This removes the scoreCachedTempo from main channel struct, it was
observed that with advent of on demand frame loading, the tempo is
automatically being overwritten when found in score, this renders
previous logic to cache tempo and carry to forward useless.

`More Puppets` of 'theapartment-4` is now working.
This commit is contained in:
Harishankar Kumar 2023-07-16 22:25:34 +05:30 committed by Eugene Sandulenko
parent 329e63b662
commit e13eba2162
3 changed files with 8 additions and 16 deletions

View File

@ -2612,7 +2612,7 @@ void LB::b_puppetSprite(int nargs) {
}
void LB::b_puppetTempo(int nargs) {
g_director->getCurrentMovie()->getScore()->_puppetTempo = g_lingo->pop().asInt();
g_director->getCurrentMovie()->getScore()->setPuppetTempo(g_lingo->pop().asInt());
}
void LB::b_puppetTransition(int nargs) {

View File

@ -63,7 +63,6 @@ Score::Score(Movie *movie) {
_soundManager = _window->getSoundManager();
_puppetTempo = 0x00;
_puppetPalette = false;
_paletteTransitionIndex = 0;
memset(_paletteSnapshotBuffer, 0, 768);
@ -109,6 +108,10 @@ Score::~Score() {
}
}
void Score::setPuppetTempo(int16 puppetTempo) {
_currentFrame->_mainChannels.tempo = puppetTempo;
}
CastMemberID Score::getCurrentPalette() {
return g_director->_lastPalette;
}
@ -448,13 +451,7 @@ void Score::update() {
loadFrame(_curFrameNumber);
byte tempo = _currentFrame->_mainChannels.scoreCachedTempo;
// puppetTempo is overridden by changes in score tempo
if (_currentFrame->_mainChannels.tempo || tempo != _lastTempo) {
_puppetTempo = 0;
} else if (_puppetTempo) {
tempo = _puppetTempo;
}
byte tempo = _currentFrame->_mainChannels.tempo;
if (tempo) {
const bool waitForClickOnly = _vm->getVersion() < 300;
@ -1531,12 +1528,6 @@ bool Score::readOneFrame() {
debugC(4, kDebugLoading, "%s", _currentFrame->formatChannelInfo().c_str());
}
// Precache the current FPS tempo, as this carries forward to frames to the right
// of the instruction
// Delay type tempos (e.g. wait commands, delays) apply to only a single frame, and are ignored here
if (_currentFrame->_mainChannels.tempo && _currentFrame->_mainChannels.tempo <= 120)
_currentTempo = _currentFrame->_mainChannels.tempo;
_currentFrame->_mainChannels.scoreCachedTempo = _currentFrame->_mainChannels.tempo ? _currentFrame->_mainChannels.tempo : _currentTempo;
// Precache the current palette ID, as this carries forward to frames to the right
// of the instruction
if (!_currentFrame->_mainChannels.palette.paletteId.isNull())

View File

@ -103,6 +103,8 @@ public:
int getNextFrame() { return _nextFrame; }
uint16 getFramesNum() { return _numFrames; }
void setPuppetTempo(int16 puppetTempo);
CastMemberID getCurrentPalette();
Channel *getChannelById(uint16 id);
@ -169,7 +171,6 @@ public:
byte _currentFrameRate;
byte _puppetTempo;
bool _puppetPalette;
int _paletteTransitionIndex;
byte _paletteSnapshotBuffer[768];