various music related changes and cleanup; also modified MonkeyVGA music sync, at least the intro is much better synced now; not sure about other parts of it / other games
svn-id: r7237
This commit is contained in:
parent
e3acde9f9c
commit
48293bd132
7 changed files with 40 additions and 56 deletions
|
@ -188,7 +188,7 @@ bool Scumm::loadState(int slot, bool compat, SaveFileManager *mgr) {
|
||||||
|
|
||||||
initBGBuffers(_scrHeight);
|
initBGBuffers(_scrHeight);
|
||||||
|
|
||||||
if ((_features & GF_AUDIOTRACKS) && _vars[VAR_MI1_TIMER] > 0)
|
if ((_features & GF_AUDIOTRACKS) && _vars[VAR_MUSIC_TIMER] > 0)
|
||||||
_sound->startCDTimer();
|
_sound->startCDTimer();
|
||||||
|
|
||||||
CHECK_HEAP debug(1, "State loaded from '%s'", filename);
|
CHECK_HEAP debug(1, "State loaded from '%s'", filename);
|
||||||
|
|
|
@ -2053,7 +2053,7 @@ void Scumm_v5::o5_startScript() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scumm_v5::o5_startSound() {
|
void Scumm_v5::o5_startSound() {
|
||||||
_vars[VAR_MUSIC_FLAG] = 0;
|
_vars[VAR_MUSIC_TIMER] = 0;
|
||||||
_sound->addSoundToQueue(getVarOrDirectByte(0x80));
|
_sound->addSoundToQueue(getVarOrDirectByte(0x80));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2474,7 +2474,7 @@ void Scumm_v5::decodeParseString() {
|
||||||
int delay = (uint16)getVarOrDirectWord(0x40);
|
int delay = (uint16)getVarOrDirectWord(0x40);
|
||||||
|
|
||||||
if (_gameId == GID_LOOM256) {
|
if (_gameId == GID_LOOM256) {
|
||||||
_vars[VAR_MI1_TIMER] = 0;
|
_vars[VAR_MUSIC_TIMER] = 0;
|
||||||
if (offset == 0 && delay == 0) {
|
if (offset == 0 && delay == 0) {
|
||||||
_sound->stopCD();
|
_sound->stopCD();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1056,7 +1056,7 @@ public:
|
||||||
byte VAR_TMR_1;
|
byte VAR_TMR_1;
|
||||||
byte VAR_TMR_2;
|
byte VAR_TMR_2;
|
||||||
byte VAR_TMR_3;
|
byte VAR_TMR_3;
|
||||||
byte VAR_MUSIC_FLAG;
|
byte VAR_MUSIC_TIMER;
|
||||||
byte VAR_ACTOR_RANGE_MIN;
|
byte VAR_ACTOR_RANGE_MIN;
|
||||||
byte VAR_ACTOR_RANGE_MAX;
|
byte VAR_ACTOR_RANGE_MAX;
|
||||||
byte VAR_CAMERA_MIN_X;
|
byte VAR_CAMERA_MIN_X;
|
||||||
|
@ -1111,9 +1111,7 @@ public:
|
||||||
byte VAR_NEW_ROOM;
|
byte VAR_NEW_ROOM;
|
||||||
byte VAR_VERSION;
|
byte VAR_VERSION;
|
||||||
|
|
||||||
byte VAR_MI1_TIMER;
|
|
||||||
byte VAR_V5_TALK_STRING_Y;
|
byte VAR_V5_TALK_STRING_Y;
|
||||||
byte VAR_V5_CHARFLAG;
|
|
||||||
|
|
||||||
byte VAR_V6_SCREEN_WIDTH;
|
byte VAR_V6_SCREEN_WIDTH;
|
||||||
byte VAR_V6_SCREEN_HEIGHT;
|
byte VAR_V6_SCREEN_HEIGHT;
|
||||||
|
|
|
@ -699,7 +699,7 @@ void Scumm::initScummVars() {
|
||||||
// Setup light
|
// Setup light
|
||||||
_vars[VAR_CURRENT_LIGHTS] = LIGHTMODE_actor_base | LIGHTMODE_actor_color | LIGHTMODE_screen;
|
_vars[VAR_CURRENT_LIGHTS] = LIGHTMODE_actor_base | LIGHTMODE_actor_color | LIGHTMODE_screen;
|
||||||
} else {
|
} 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?
|
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) {
|
int Scumm::scummLoop(int delta) {
|
||||||
static int counter = 0;
|
|
||||||
|
|
||||||
#ifndef _WIN32_WCE
|
#ifndef _WIN32_WCE
|
||||||
if (_debugger)
|
if (_debugger)
|
||||||
_debugger->on_frame();
|
_debugger->on_frame();
|
||||||
|
@ -771,23 +769,30 @@ int Scumm::scummLoop(int delta) {
|
||||||
_vars[VAR_MOUSE_Y] = mouse.y;
|
_vars[VAR_MOUSE_Y] = mouse.y;
|
||||||
_vars[VAR_DEBUGMODE] = _debugMode;
|
_vars[VAR_DEBUGMODE] = _debugMode;
|
||||||
|
|
||||||
if (_gameId == GID_MONKEY_VGA) {
|
if (_features & GF_AUDIOTRACKS) {
|
||||||
// FIXME: Is all this really necessary now?
|
// Covered automatically by the Sound class
|
||||||
if (delta == 1)
|
} else if ((_features & GF_OLD256) || (_features & GF_16COLOR) || (_gameId == GID_MONKEY_VGA)) {
|
||||||
_vars[VAR_MI1_TIMER]++;
|
// Original values:
|
||||||
else if (++counter != 2)
|
//const int ITERATIONS = 4;
|
||||||
_vars[VAR_MI1_TIMER] += 5;
|
//const int INCREMENT = 1;
|
||||||
else {
|
|
||||||
counter = 0;
|
// This function (scummLoop) is invoked roughly every delta*15 milliseconds.
|
||||||
_vars[VAR_MI1_TIMER] += 6;
|
// In GID_MONKEY_VGA, delta usually is 5 or 6, hence this function is called
|
||||||
}
|
// every 75-90 ms.
|
||||||
} else if (_features & GF_AUDIOTRACKS) {
|
// With the original values, we incremented VAR_MUSIC_TIMER every fourth
|
||||||
_vars[VAR_MI1_TIMER] = _sound->readCDTimer();
|
// iteration by 1. That corresponds to a time interval of 18.75 / 22.5 ms.
|
||||||
} else if ((_features & GF_OLD256) || (_features & GF_16COLOR)) {
|
//
|
||||||
|
// With the new values, we have a ratio of 3/11 = 0.272727... which makes
|
||||||
if(tempMusic == 3) {
|
// 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;
|
tempMusic = 0;
|
||||||
_vars[VAR_MUSIC_FLAG]++;
|
_vars[VAR_MUSIC_TIMER] += INCREMENT;
|
||||||
} else {
|
} else {
|
||||||
tempMusic++;
|
tempMusic++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,7 +185,7 @@ void Sound::playSound(int soundID) {
|
||||||
}
|
}
|
||||||
else if (READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) {
|
else if (READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) {
|
||||||
ptr += 8;
|
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],
|
playCDTrack(ptr[16], ptr[17] == 0xff ? -1 : ptr[17],
|
||||||
(ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0);
|
(ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0);
|
||||||
|
|
||||||
|
@ -782,7 +782,7 @@ void Sound::pauseSounds(bool pause) {
|
||||||
_scumm->_imuseDigital->pause(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)
|
if (pause)
|
||||||
stopCDTimer();
|
stopCDTimer();
|
||||||
else
|
else
|
||||||
|
@ -1388,20 +1388,11 @@ int Sound::playSfxSound_Vorbis(void *sound, uint32 size) {
|
||||||
static void cd_timer_handler(void *ptr) {
|
static void cd_timer_handler(void *ptr) {
|
||||||
Scumm *scumm = (Scumm *) 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
|
// 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
|
// 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.
|
// properly restarted when reloading a saved game, I don't dare to.
|
||||||
|
|
||||||
scumm->_sound->_cd_timer_value += 6;
|
scumm->_vars[scumm->VAR_MUSIC_TIMER] += 6;
|
||||||
}
|
|
||||||
|
|
||||||
int Sound::readCDTimer() {
|
|
||||||
return _cd_timer_value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::startCDTimer() {
|
void Sound::startCDTimer() {
|
||||||
|
@ -1418,7 +1409,6 @@ void Sound::startCDTimer() {
|
||||||
timer_interval = 101;
|
timer_interval = 101;
|
||||||
|
|
||||||
_scumm->_timer->releaseProcedure(&cd_timer_handler);
|
_scumm->_timer->releaseProcedure(&cd_timer_handler);
|
||||||
_cd_timer_value = _scumm->_vars[_scumm->VAR_MI1_TIMER];
|
|
||||||
_scumm->_timer->installProcedure(&cd_timer_handler, 1000 * timer_interval);
|
_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 Sound::playMP3CDTrack(int track, int num_loops, int start, int delay) {
|
||||||
int index;
|
int index;
|
||||||
_scumm->_vars[_scumm->VAR_MI1_TIMER] = 0;
|
_scumm->_vars[_scumm->VAR_MUSIC_TIMER] = 0;
|
||||||
|
|
||||||
if (_soundsPaused)
|
if (_soundsPaused)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -133,7 +133,6 @@ public:
|
||||||
int32 _bundleMusicPosition;
|
int32 _bundleMusicPosition;
|
||||||
|
|
||||||
int _talkChannel; /* Mixer channel actor is talking on */
|
int _talkChannel; /* Mixer channel actor is talking on */
|
||||||
int _cd_timer_value;
|
|
||||||
bool _soundsPaused;
|
bool _soundsPaused;
|
||||||
int16 _sound_volume_master, _sound_volume_music, _sound_volume_sfx;
|
int16 _sound_volume_master, _sound_volume_music, _sound_volume_sfx;
|
||||||
byte _sfxMode;
|
byte _sfxMode;
|
||||||
|
@ -173,7 +172,6 @@ public:
|
||||||
int playSfxSound_MP3(void *sound, uint32 size);
|
int playSfxSound_MP3(void *sound, uint32 size);
|
||||||
int playSfxSound_Vorbis(void *sound, uint32 size);
|
int playSfxSound_Vorbis(void *sound, uint32 size);
|
||||||
|
|
||||||
int readCDTimer();
|
|
||||||
void startCDTimer();
|
void startCDTimer();
|
||||||
void stopCDTimer();
|
void stopCDTimer();
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ void Scumm::setupScummVars() {
|
||||||
VAR_TMR_1 = 11;
|
VAR_TMR_1 = 11;
|
||||||
VAR_TMR_2 = 12;
|
VAR_TMR_2 = 12;
|
||||||
VAR_TMR_3 = 13;
|
VAR_TMR_3 = 13;
|
||||||
VAR_MUSIC_FLAG = 14;
|
VAR_MUSIC_TIMER = 14;
|
||||||
VAR_ACTOR_RANGE_MIN = 15;
|
VAR_ACTOR_RANGE_MIN = 15;
|
||||||
VAR_ACTOR_RANGE_MAX = 16;
|
VAR_ACTOR_RANGE_MAX = 16;
|
||||||
VAR_CAMERA_MIN_X = 17;
|
VAR_CAMERA_MIN_X = 17;
|
||||||
|
@ -94,10 +94,12 @@ void Scumm::setupScummVars() {
|
||||||
VAR_NEW_ROOM = 72; // Zak256 Note: Cashcard for Leslie
|
VAR_NEW_ROOM = 72; // Zak256 Note: Cashcard for Leslie
|
||||||
VAR_VERSION = 75;
|
VAR_VERSION = 75;
|
||||||
|
|
||||||
VAR_MI1_TIMER = 14;
|
|
||||||
|
|
||||||
VAR_V5_TALK_STRING_Y = 54;
|
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_WIDTH = 41;
|
||||||
VAR_V6_SCREEN_HEIGHT = 54;
|
VAR_V6_SCREEN_HEIGHT = 54;
|
||||||
|
@ -105,11 +107,6 @@ void Scumm::setupScummVars() {
|
||||||
VAR_V6_RANDOM_NR = 118;
|
VAR_V6_RANDOM_NR = 118;
|
||||||
|
|
||||||
VAR_V6_SOUNDMODE = 9;
|
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_YEAR = 119;
|
||||||
VAR_TIMEDATE_MONTH = 129;
|
VAR_TIMEDATE_MONTH = 129;
|
||||||
|
@ -142,6 +139,7 @@ void Scumm_v7::setupScummVars() {
|
||||||
VAR_PERFORMANCE_1 = 26;
|
VAR_PERFORMANCE_1 = 26;
|
||||||
VAR_PERFORMANCE_2 = 27;
|
VAR_PERFORMANCE_2 = 27;
|
||||||
VAR_GAME_LOADED = 29;
|
VAR_GAME_LOADED = 29;
|
||||||
|
VAR_V6_EMSSPACE = 32;
|
||||||
VAR_V6_RANDOM_NR = 34;
|
VAR_V6_RANDOM_NR = 34;
|
||||||
VAR_NEW_ROOM = 35;
|
VAR_NEW_ROOM = 35;
|
||||||
VAR_WALKTO_OBJ = 36;
|
VAR_WALKTO_OBJ = 36;
|
||||||
|
@ -198,11 +196,6 @@ void Scumm_v7::setupScummVars() {
|
||||||
VAR_VIDEONAME = 123;
|
VAR_VIDEONAME = 123;
|
||||||
VAR_CUSTOMSCALETABLE = 131;
|
VAR_CUSTOMSCALETABLE = 131;
|
||||||
|
|
||||||
VAR_MI1_TIMER = 14;
|
|
||||||
VAR_V5_TALK_STRING_Y = 54;
|
|
||||||
VAR_V5_CHARFLAG = 60;
|
|
||||||
|
|
||||||
VAR_V6_EMSSPACE = 32;
|
|
||||||
VAR_STRING2DRAW = 130;
|
VAR_STRING2DRAW = 130;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +296,7 @@ void Scumm_v2::setupScummVars() {
|
||||||
VAR_NUM_ACTOR = 11;
|
VAR_NUM_ACTOR = 11;
|
||||||
VAR_CURRENT_LIGHTS = 12;
|
VAR_CURRENT_LIGHTS = 12;
|
||||||
VAR_CURRENTDRIVE = 13;
|
VAR_CURRENTDRIVE = 13;
|
||||||
VAR_MUSIC_FLAG = 17;
|
VAR_MUSIC_TIMER = 17;
|
||||||
VAR_ACTOR_RANGE_MIN = 19;
|
VAR_ACTOR_RANGE_MIN = 19;
|
||||||
VAR_ACTOR_RANGE_MAX = 20;
|
VAR_ACTOR_RANGE_MAX = 20;
|
||||||
VAR_CAMERA_MIN_X = 23;
|
VAR_CAMERA_MIN_X = 23;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue