diff options
-rw-r--r-- | scumm/saveload.cpp | 2 | ||||
-rw-r--r-- | scumm/script_v5.cpp | 4 | ||||
-rw-r--r-- | scumm/scumm.h | 4 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 43 | ||||
-rw-r--r-- | scumm/sound.cpp | 18 | ||||
-rw-r--r-- | scumm/sound.h | 2 | ||||
-rw-r--r-- | scumm/vars.cpp | 23 |
7 files changed, 40 insertions, 56 deletions
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index 3454e02e85..9258480bc6 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -188,7 +188,7 @@ bool Scumm::loadState(int slot, bool compat, SaveFileManager *mgr) { initBGBuffers(_scrHeight); - if ((_features & GF_AUDIOTRACKS) && _vars[VAR_MI1_TIMER] > 0) + if ((_features & GF_AUDIOTRACKS) && _vars[VAR_MUSIC_TIMER] > 0) _sound->startCDTimer(); CHECK_HEAP debug(1, "State loaded from '%s'", filename); diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp index e3bcdaa8a1..0946a18c41 100644 --- a/scumm/script_v5.cpp +++ b/scumm/script_v5.cpp @@ -2053,7 +2053,7 @@ void Scumm_v5::o5_startScript() { } void Scumm_v5::o5_startSound() { - _vars[VAR_MUSIC_FLAG] = 0; + _vars[VAR_MUSIC_TIMER] = 0; _sound->addSoundToQueue(getVarOrDirectByte(0x80)); } @@ -2474,7 +2474,7 @@ void Scumm_v5::decodeParseString() { int delay = (uint16)getVarOrDirectWord(0x40); if (_gameId == GID_LOOM256) { - _vars[VAR_MI1_TIMER] = 0; + _vars[VAR_MUSIC_TIMER] = 0; if (offset == 0 && delay == 0) { _sound->stopCD(); } else { diff --git a/scumm/scumm.h b/scumm/scumm.h index f90860cefa..6a105e617b 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -1056,7 +1056,7 @@ public: byte VAR_TMR_1; byte VAR_TMR_2; byte VAR_TMR_3; - byte VAR_MUSIC_FLAG; + byte VAR_MUSIC_TIMER; byte VAR_ACTOR_RANGE_MIN; byte VAR_ACTOR_RANGE_MAX; byte VAR_CAMERA_MIN_X; @@ -1111,9 +1111,7 @@ public: byte VAR_NEW_ROOM; byte VAR_VERSION; - byte VAR_MI1_TIMER; byte VAR_V5_TALK_STRING_Y; - byte VAR_V5_CHARFLAG; byte VAR_V6_SCREEN_WIDTH; byte VAR_V6_SCREEN_HEIGHT; diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 6ea7df9b2a..d9c2f67332 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -699,7 +699,7 @@ void Scumm::initScummVars() { // Setup light _vars[VAR_CURRENT_LIGHTS] = LIGHTMODE_actor_base | LIGHTMODE_actor_color | LIGHTMODE_screen; } else { - _vars[VAR_V6_EMSSPACE] = 10000; + _vars[VAR_V6_EMSSPACE] = 10000; } if (_features & GF_AFTER_V8) { // Fixme: How do we deal with non-cd installs? @@ -725,8 +725,6 @@ void Scumm::checkRange(int max, int min, int no, const char *str) { } int Scumm::scummLoop(int delta) { - static int counter = 0; - #ifndef _WIN32_WCE if (_debugger) _debugger->on_frame(); @@ -771,23 +769,30 @@ int Scumm::scummLoop(int delta) { _vars[VAR_MOUSE_Y] = mouse.y; _vars[VAR_DEBUGMODE] = _debugMode; - if (_gameId == GID_MONKEY_VGA) { - // FIXME: Is all this really necessary now? - if (delta == 1) - _vars[VAR_MI1_TIMER]++; - else if (++counter != 2) - _vars[VAR_MI1_TIMER] += 5; - else { - counter = 0; - _vars[VAR_MI1_TIMER] += 6; - } - } else if (_features & GF_AUDIOTRACKS) { - _vars[VAR_MI1_TIMER] = _sound->readCDTimer(); - } else if ((_features & GF_OLD256) || (_features & GF_16COLOR)) { - - if(tempMusic == 3) { + if (_features & GF_AUDIOTRACKS) { + // Covered automatically by the Sound class + } else if ((_features & GF_OLD256) || (_features & GF_16COLOR) || (_gameId == GID_MONKEY_VGA)) { + // Original values: + //const int ITERATIONS = 4; + //const int INCREMENT = 1; + + // This function (scummLoop) is invoked roughly every delta*15 milliseconds. + // In GID_MONKEY_VGA, delta usually is 5 or 6, hence this function is called + // every 75-90 ms. + // With the original values, we incremented VAR_MUSIC_TIMER every fourth + // iteration by 1. That corresponds to a time interval of 18.75 / 22.5 ms. + // + // With the new values, we have a ratio of 3/11 = 0.272727... which makes + // the GID_MONKEY_VGA intro synced quite perfectly on my system. But I am not sure + // which impact this might have on other games, or on other parts in MI. + // However, even with the 4/1 values this seems much better than the old code + // for handling GID_MONKEY_VGA... + const int ITERATIONS = 11; + const int INCREMENT = 3; + + if (tempMusic == ITERATIONS-1) { tempMusic = 0; - _vars[VAR_MUSIC_FLAG]++; + _vars[VAR_MUSIC_TIMER] += INCREMENT; } else { tempMusic++; } diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 7b7f6ed5f6..a34b9d83b9 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -185,7 +185,7 @@ void Sound::playSound(int soundID) { } else if (READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) { ptr += 8; - _scumm->_vars[_scumm->VAR_MI1_TIMER] = 0; + _scumm->_vars[_scumm->VAR_MUSIC_TIMER] = 0; playCDTrack(ptr[16], ptr[17] == 0xff ? -1 : ptr[17], (ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0); @@ -782,7 +782,7 @@ void Sound::pauseSounds(bool pause) { _scumm->_imuseDigital->pause(pause); } - if ((_scumm->_features & GF_AUDIOTRACKS) && _scumm->_vars[_scumm->VAR_MI1_TIMER] > 0) { + if ((_scumm->_features & GF_AUDIOTRACKS) && _scumm->_vars[_scumm->VAR_MUSIC_TIMER] > 0) { if (pause) stopCDTimer(); else @@ -1388,20 +1388,11 @@ int Sound::playSfxSound_Vorbis(void *sound, uint32 size) { static void cd_timer_handler(void *ptr) { Scumm *scumm = (Scumm *) ptr; - // Maybe I could simply update _vars[VAR_MI1_TIMER] directly here, but - // I don't feel comfortable just doing that from what might be a - // separate thread. If someone tells me it's safe, I'll make the - // change right away. - // FIXME: Turn off the timer when it's no longer needed. In theory, it // should be possible to check with pollCD(), but since CD sound isn't // properly restarted when reloading a saved game, I don't dare to. - scumm->_sound->_cd_timer_value += 6; -} - -int Sound::readCDTimer() { - return _cd_timer_value; + scumm->_vars[scumm->VAR_MUSIC_TIMER] += 6; } void Sound::startCDTimer() { @@ -1418,7 +1409,6 @@ void Sound::startCDTimer() { timer_interval = 101; _scumm->_timer->releaseProcedure(&cd_timer_handler); - _cd_timer_value = _scumm->_vars[_scumm->VAR_MI1_TIMER]; _scumm->_timer->installProcedure(&cd_timer_handler, 1000 * timer_interval); } @@ -1518,7 +1508,7 @@ int Sound::getCachedTrack(int track) { int Sound::playMP3CDTrack(int track, int num_loops, int start, int delay) { int index; - _scumm->_vars[_scumm->VAR_MI1_TIMER] = 0; + _scumm->_vars[_scumm->VAR_MUSIC_TIMER] = 0; if (_soundsPaused) return 0; diff --git a/scumm/sound.h b/scumm/sound.h index 8f55a38b44..3afac58f80 100644 --- a/scumm/sound.h +++ b/scumm/sound.h @@ -133,7 +133,6 @@ public: int32 _bundleMusicPosition; int _talkChannel; /* Mixer channel actor is talking on */ - int _cd_timer_value; bool _soundsPaused; int16 _sound_volume_master, _sound_volume_music, _sound_volume_sfx; byte _sfxMode; @@ -173,7 +172,6 @@ public: int playSfxSound_MP3(void *sound, uint32 size); int playSfxSound_Vorbis(void *sound, uint32 size); - int readCDTimer(); void startCDTimer(); void stopCDTimer(); diff --git a/scumm/vars.cpp b/scumm/vars.cpp index 5c9f3cf236..cd2024fc73 100644 --- a/scumm/vars.cpp +++ b/scumm/vars.cpp @@ -40,7 +40,7 @@ void Scumm::setupScummVars() { VAR_TMR_1 = 11; VAR_TMR_2 = 12; VAR_TMR_3 = 13; - VAR_MUSIC_FLAG = 14; + VAR_MUSIC_TIMER = 14; VAR_ACTOR_RANGE_MIN = 15; VAR_ACTOR_RANGE_MAX = 16; VAR_CAMERA_MIN_X = 17; @@ -94,10 +94,12 @@ void Scumm::setupScummVars() { VAR_NEW_ROOM = 72; // Zak256 Note: Cashcard for Leslie VAR_VERSION = 75; - VAR_MI1_TIMER = 14; - VAR_V5_TALK_STRING_Y = 54; - VAR_V5_CHARFLAG = 60; +} + +void Scumm_v6::setupScummVars() { + // Many vars are the same as in V5 games, so just call the inherited method first + Scumm::setupScummVars(); VAR_V6_SCREEN_WIDTH = 41; VAR_V6_SCREEN_HEIGHT = 54; @@ -105,11 +107,6 @@ void Scumm::setupScummVars() { VAR_V6_RANDOM_NR = 118; VAR_V6_SOUNDMODE = 9; -} - -void Scumm_v6::setupScummVars() { - // Many vars are the same as in V5 games, so just call the inherited method first - Scumm::setupScummVars(); VAR_TIMEDATE_YEAR = 119; VAR_TIMEDATE_MONTH = 129; @@ -142,6 +139,7 @@ void Scumm_v7::setupScummVars() { VAR_PERFORMANCE_1 = 26; VAR_PERFORMANCE_2 = 27; VAR_GAME_LOADED = 29; + VAR_V6_EMSSPACE = 32; VAR_V6_RANDOM_NR = 34; VAR_NEW_ROOM = 35; VAR_WALKTO_OBJ = 36; @@ -198,11 +196,6 @@ void Scumm_v7::setupScummVars() { VAR_VIDEONAME = 123; VAR_CUSTOMSCALETABLE = 131; - VAR_MI1_TIMER = 14; - VAR_V5_TALK_STRING_Y = 54; - VAR_V5_CHARFLAG = 60; - - VAR_V6_EMSSPACE = 32; VAR_STRING2DRAW = 130; } @@ -303,7 +296,7 @@ void Scumm_v2::setupScummVars() { VAR_NUM_ACTOR = 11; VAR_CURRENT_LIGHTS = 12; VAR_CURRENTDRIVE = 13; - VAR_MUSIC_FLAG = 17; + VAR_MUSIC_TIMER = 17; VAR_ACTOR_RANGE_MIN = 19; VAR_ACTOR_RANGE_MAX = 20; VAR_CAMERA_MIN_X = 23; |