Ticket #8058: cd-timer.diff
File cd-timer.diff, 4.5 KB (added by , 22 years ago) |
---|
-
scummvm/scumm/saveload.cpp
diff -ur ScummVM-cvs20020919/scummvm/scumm/saveload.cpp ScummVM-cvs20020919+hack/scummvm/scumm/saveload.cpp
old new 159 159 160 160 initBGBuffers(_scrHeight); 161 161 162 _sound->resumeCDTimer(); 163 162 164 CHECK_HEAP debug(1, "State loaded from '%s'", filename); 163 165 164 166 -
scummvm/scumm/scummvm.cpp
diff -ur ScummVM-cvs20020919/scummvm/scumm/scummvm.cpp ScummVM-cvs20020919+hack/scummvm/scumm/scummvm.cpp
old new 331 331 332 332 int Scumm::scummLoop(int delta) 333 333 { 334 static int counter = 0;335 336 334 #ifndef _WIN32_WCE 337 335 if (_debugger) 338 336 _debugger->on_frame(); … … 371 369 _vars[VAR_MOUSE_Y] = mouse.y; 372 370 _vars[VAR_DEBUGMODE] = _debugMode; 373 371 374 if (_features & GF_AUDIOTRACKS) { 375 if (delta) { 376 if (delta == 1) { 377 // Better sync with the Loom CD intro 378 _vars[VAR_MI1_TIMER]++; 379 } else if (++counter != 2) 380 _vars[VAR_MI1_TIMER] += 5; 381 else { 382 counter = 0; 383 _vars[VAR_MI1_TIMER] += 6; 384 } 385 } 372 if (_features & GF_AUDIOTRACKS) { 373 _vars[VAR_MI1_TIMER] = _sound->readCDTimer(); 386 374 } else if (_features & GF_OLD256) { 387 375 388 376 if(tempMusic == 3) { -
scummvm/scumm/sound.cpp
diff -ur ScummVM-cvs20020919/scummvm/scumm/sound.cpp ScummVM-cvs20020919+hack/scummvm/scumm/sound.cpp
old new 1028 1028 return -1; 1029 1029 } 1030 1030 1031 // We use a real timer in an attempt to get better sync with CD tracks. This is 1032 // necessary for games like Loom CD. 1033 1034 static void cd_timer_handler(void *ptr) 1035 { 1036 Scumm *scumm = (Scumm *) ptr; 1037 scumm->_sound->_cd_timer_value += 5; 1038 } 1039 1040 int Sound::readCDTimer() 1041 { 1042 return _cd_timer_value; 1043 } 1044 1045 void Sound::startCDTimer() 1046 { 1047 int timer_interval; 1048 1049 // The timer interval has been tuned for Loom CD and the Monkey 1 1050 // intro. I have to use 83 for Loom, or there will be a nasty stutter 1051 // when Chaos first appears, and I have to use 84 for Monkey 1 or the 1052 // intro music will be cut short. 1053 1054 if (_scumm->_gameId == GID_LOOM256) 1055 timer_interval = 83; 1056 else 1057 timer_interval = 84; 1058 1059 _scumm->_timer->installProcedure(&cd_timer_handler, timer_interval); 1060 } 1061 1062 void Sound::stopCDTimer() 1063 { 1064 _cd_timer_value = 0; 1065 _scumm->_timer->releaseProcedure(&cd_timer_handler); 1066 if (_scumm->_features & GF_AUDIOTRACKS) { 1067 _scumm->_vars[_scumm->VAR_MI1_TIMER] = 0; 1068 } 1069 } 1070 1071 void Sound::restartCDTimer() 1072 { 1073 stopCDTimer(); 1074 startCDTimer(); 1075 } 1076 1077 void Sound::resumeCDTimer() 1078 { 1079 // This function will be called after a savegame has been reloaded, 1080 // in case we have to get the timer running again. 1081 1082 if ((_scumm->_features & GF_AUDIOTRACKS) && _scumm->_vars[_scumm->VAR_MI1_TIMER] > 0) { 1083 _cd_timer_value = _scumm->_vars[_scumm->VAR_MI1_TIMER]; 1084 startCDTimer(); 1085 } 1086 } 1087 1031 1088 void Sound::playCDTrack(int track, int num_loops, int start, int delay) 1032 1089 { 1033 1090 #ifdef COMPRESSED_SOUND_FILE 1034 1091 if (playMP3CDTrack(track, num_loops, start, delay) == -1) 1035 1092 #endif 1036 1093 _scumm->_system->play_cdrom(track, num_loops, start, delay); 1094 1095 // Start the timer after starting the track. Starting an MP3 track is 1096 // almost instantaneous, but a CD player may take some time. Hopefully 1097 // play_cdrom() will block during that delay. 1098 1099 restartCDTimer(); 1037 1100 } 1038 1101 1039 1102 void Sound::stopCD() 1040 1103 { 1104 stopCDTimer(); 1041 1105 #ifdef COMPRESSED_SOUND_FILE 1042 1106 if (stopMP3CD() == -1) 1043 1107 #endif -
scummvm/scumm/sound.h
diff -ur ScummVM-cvs20020919/scummvm/scumm/sound.h ScummVM-cvs20020919+hack/scummvm/scumm/sound.h
old new 23 23 24 24 #include "scummsys.h" 25 25 #include "sound/mixer.h" 26 #include "common/timer.h" 26 27 27 28 class Scumm; 28 29 class File; … … 88 89 89 90 #endif 90 91 92 int _cd_timer_value; 91 93 bool _soundsPaused; 92 94 int16 _sound_volume_master, _sound_volume_music, _sound_volume_sfx; 93 95 byte _sfxMode; … … 124 126 int playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned); 125 127 int playSfxSound_MP3(void *sound, uint32 size); 126 128 129 int readCDTimer(); 130 void startCDTimer(); 131 void stopCDTimer(); 132 void restartCDTimer(); 133 void resumeCDTimer(); 134 127 135 void playCDTrack(int track, int num_loops, int start, int delay); 128 136 void stopCD(); 129 137 int pollCD();