- Just warn, don't die, when a CD-Track isn't found

- Before using _vm->_adlib, first check whether it's actually there

svn-id: r25205
This commit is contained in:
Sven Hesse 2007-01-26 19:00:41 +00:00
parent d2910fe758
commit 8e6cd81333
7 changed files with 31 additions and 23 deletions

View File

@ -172,7 +172,7 @@ void CDROM::startTrack(const char *trackname) {
}
if (!matchPtr) {
error("Track %s not found", trackname);
warning("Track %s not found", trackname);
return;
}

View File

@ -352,7 +352,7 @@ void Game::freeSoundSlot(int16 slot) {
return;
if (_soundADL[slot]) {
if (_vm->_adlib->getIndex() == slot)
if (_vm->_adlib && (_vm->_adlib->getIndex() == slot))
_vm->_adlib->stopPlay();
if (_soundFromExt[slot] == 1) {
delete[] ((char *) _soundSamples[slot]);

View File

@ -81,9 +81,10 @@ void Game_v1::playTot(int16 skipPlay) {
_vm->_draw->_fontToSprite[i].height = -1;
}
if (_vm->_features & GF_MAC)
_vm->_adlib->stopPlay();
else
if (_vm->_features & GF_MAC) {
if (_vm->_adlib)
_vm->_adlib->stopPlay();
} else
_vm->_cdrom->stopPlaying();
_vm->_draw->animateCursor(4);
_vm->_inter->initControlVars(1);

View File

@ -73,9 +73,10 @@ void Game_v2::playTot(int16 skipPlay) {
while (!_vm->_quitRequested) {
if (_vm->_global->_inter_variables != 0)
_vm->_draw->animateCursor(4);
if (_vm->_features & GF_MAC)
_vm->_adlib->stopPlay();
else
if (_vm->_features & GF_MAC) {
if (_vm->_adlib)
_vm->_adlib->stopPlay();
} else
_vm->_cdrom->stopPlaying();
if (skipPlay != -1) {

View File

@ -1210,7 +1210,8 @@ bool Inter_v1::o1_playComposition(char &cmdCount, int16 &counter, int16 &retFlag
}
bool Inter_v1::o1_stopSound(char &cmdCount, int16 &counter, int16 &retFlag) {
_vm->_adlib->stopPlay();
if (_vm->_adlib)
_vm->_adlib->stopPlay();
_vm->_snd->stopSound(_vm->_parse->parseValExpr());
_soundEndTimeKey = 0;
return false;
@ -1640,9 +1641,10 @@ void Inter_v1::o1_loadCurLayer(void) {
void Inter_v1::o1_playCDTrack(void) {
evalExpr(0);
if (_vm->_features & GF_MAC)
_vm->_adlib->playTrack(_vm->_global->_inter_resStr);
else
if (_vm->_features & GF_MAC) {
if (_vm->_adlib)
_vm->_adlib->playTrack(_vm->_global->_inter_resStr);
} else
// Used in gob1 CD
_vm->_cdrom->startTrack(_vm->_global->_inter_resStr);
}
@ -1663,9 +1665,10 @@ void Inter_v1::o1_getCDTrackPos(void) {
}
void Inter_v1::o1_stopCD(void) {
if (_vm->_features & GF_MAC)
_vm->_adlib->stopPlay();
else
if (_vm->_features & GF_MAC) {
if (_vm->_adlib)
_vm->_adlib->stopPlay();
} else
// Used in gob1 CD
_vm->_cdrom->stopPlaying();
}
@ -2587,9 +2590,10 @@ void Inter_v1::o1_animateObjects(int16 &extraData, int32 *retVarPtr, Goblin::Gob
void Inter_v1::o1_drawObjects(int16 &extraData, int32 *retVarPtr, Goblin::Gob_Object *objDesc) {
_vm->_goblin->drawObjects();
if (_vm->_features & GF_MAC)
_vm->_adlib->playBgMusic();
else if (_vm->_cdrom->getTrackPos() == -1)
if (_vm->_features & GF_MAC) {
if (_vm->_adlib)
_vm->_adlib->playBgMusic();
} else if (_vm->_cdrom->getTrackPos() == -1)
_vm->_cdrom->playBgMusic();
}

View File

@ -1601,10 +1601,12 @@ bool Inter_v2::o2_playSound(char &cmdCount, int16 &counter, int16 &retFlag) {
_vm->_game->_soundSamples[index]->size / 2) * 1000) / freq2;
}
// loc_E2F3
if (_vm->_game->_soundTypes[index] & 8) {
_vm->_adlib->load((byte *) _vm->_game->_soundSamples[index], index);
_vm->_adlib->setRepeating(repCount - 1);
_vm->_adlib->startPlay();
if ((_vm->_game->_soundTypes[index] & 8)) {
if (_vm->_adlib) {
_vm->_adlib->load((byte *) _vm->_game->_soundSamples[index], index);
_vm->_adlib->setRepeating(repCount - 1);
_vm->_adlib->startPlay();
}
} else {
_vm->_snd->stopSound(0);
_vm->_snd->playSample(_vm->_game->_soundSamples[index], repCount, frequency);

View File

@ -307,7 +307,7 @@ void Adlib::setKey(byte voice, byte note, bool on, bool spec) {
_notes[voice] = note;
note += _notCol[voice];
note = MIN(0x5F, (int)note);
note = MIN((byte) 0x5F, note);
octa = note / 12;
freq = _freqs[_notLin[voice]][note - octa * 12];