XEEN: Properly convert script CD times to ScummVM CD frames

This commit is contained in:
Paul Gilbert 2018-05-05 17:14:06 -04:00
parent 057fb9bc6e
commit 856b6a08f1
2 changed files with 20 additions and 2 deletions

View File

@ -1473,15 +1473,28 @@ bool Scripts::cmdFlipWorld(ParamsIterator &params) {
bool Scripts::cmdPlayCD(ParamsIterator &params) {
int trackNum = params.readByte();
int start = params.readUint16LE() * 60 / 75;
int finish = params.readUint16LE() * 60 / 75;
int start = params.readUint16LE();
int finish = params.readUint16LE();
if (_vm->_files->_ccNum)
trackNum += 30;
assert(trackNum <= 60);
start = convertCDTime(start);
finish = convertCDTime(finish);
g_system->getAudioCDManager()->play(trackNum, 1, start, finish - start, false, Audio::Mixer::kSpeechSoundType);
return true;
}
#define CD_FRAME_RATE 75
uint Scripts::convertCDTime(uint srcTime) {
// Times are encoded as MMSSCC - MM=Minutes, SS=Seconds, CC=Centiseconds (1/100th second)
uint mins = srcTime / 10000;
uint csec = srcTime % 10000;
return (mins * 6000 + csec) * CD_FRAME_RATE / 100;
}
void Scripts::doCloudsEnding() {
g_vm->_party->_cloudsCompleted = true;
doEnding("ENDGAME");

View File

@ -544,6 +544,11 @@ private:
* Displays a message
*/
void display(bool justifyFlag, int var46);
/**
* Convert a CD time from the World of Xeen playCD opcodes to ScummVM CD frame number (which is at 75Hz)
*/
uint convertCDTime(uint srcTime);
public:
int _animCounter;
bool _eventSkipped;